Comments - CREATE TABLE
Content reproduced on this site is the property of its respective owners,
and this content is not reviewed in advance by MariaDB. The views, information and opinions
expressed by this content do not necessarily represent those of MariaDB or any other party.
The problem seems to only occur when also specifying a default value; CHARSET must be specified before any DEFAULT value:
MariaDB [data]> CREATE TABLE foo2 (id varchar(120) DEFAULT 'bar' CHARSET utf8);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'CHARSET utf8)' at line 1
Not quite MySQL compatible.
In column_definition specified above CHARSET is a part of data_type, this is why it should go before the default value; and it works exactly the same way in MySQL:
My apologies, it does seem to work the same in MySQL.
I've noticed that many SQL beginners lose much time on syntax errors, before understanding that the clauses must always follow exactly the correct order.