Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can we have the table name as "option" in MySQL?

I am very, very new to MYSQL.I tried to create a table named "option". My SQL Query is :

create table option(

id int not null primary key auto_increment,

choice varchar(30)

)

While executing this query it shows the following error

Error Code : 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'option( id int not null primary key auto_increment, choice varchar(30) )' at line 1 (0 ms taken)

If I try with the table name as "choice" it is working.

can we have the table name as "option" in mysql?

thanks

like image 923
DonX Avatar asked Nov 29 '08 17:11

DonX


2 Answers

If you want to have a table name Option, you should be able to, just remember that whenever you use the table in a query, you will have to encase it in ` symbols. Like this.

`option`

The ` key on the top left of your keyboard, with the tilde.

like image 139
Kibbee Avatar answered Sep 27 '22 18:09

Kibbee


Pick a different name (one that isn't a reserved word in your RDBMS) and save yourself and whoever else might work on it many headaches.

like image 31
Patrick Harrington Avatar answered Sep 27 '22 20:09

Patrick Harrington