I can never seem to be able to create MySQL tables with columns of the type TEXT. Here's 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's run, I get this:
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 figure out what's wrong! I'm using Java if it makes any difference.
desc
is a reserved word and shouldn't be used as a name of a column. You can use desc
as a name of a column, but if you do, you must always wrap it in back-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
);
The above is tested and works, but since you'll always have to wrap it in back-ticks (in every INSERT
, UPDATE
and DELETE
) you may want to change the name, or just get in the habit of wrapping all fields in back-ticks, which has other advantages.
change the column name desc
to any something different since it is a reserverd word for descend
or describe
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With