Syntax error Creating a table with a column named "desc"

I can never create MySQL tables with columns of type TEXT. Here is my MySQL:

CREATE TABLE factions(id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), name VARCHAR(16) NOT NULL, desc TEXT NOT NULL, admins TEXT NOT NULL, mods TEXT, members TEXT, land TEXT, enemies TEXT, allies TEXT)

When it starts, I get the following:

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 'desc text NOT NULL, admins text NOT NULL, mods text, members text, land text, en' at line 1

I can’t understand what happened! I use Java if that matters.

+5
source share
3 answers

descis a reserved word, and should not be used as a column name. You can use descas the name of the column, but if you do, you should always wrap it in reverse ticks.

CREATE TABLE factions(
   id INT NOT NULL AUTO_INCREMENT,
   PRIMARY KEY(id), 
   name    VARCHAR(16) NOT NULL, 
   `desc`  TEXT NOT NULL, 
   admins  TEXT NOT NULL, 
   mods    TEXT, 
   members TEXT, 
   land    TEXT, 
   enemies TEXT, 
   allies  TEXT
);

, ( INSERT, UPDATE DELETE) back-ticks, .

+14

desc , reserverd descend describe

+1

desc- a reserved word, but can not be omitted as the name of a table or column. You can use descriptionas a column name. With a name change, your expression should work.

0
source