0

I'm very very new to MySQL/SQL. I'm trying to create a database with a couple of tables. The first few tables created just fine, but this last one is giving me trouble. Here's what I am doing:

mysql> CREATE TABLE Order (                                                    
-> CustomerId INTEGER NOT NULL,                                                 
-> EmployeeId INTEGER,
-> Id INTEGER,
-> DT DATETIME(),
-> PRIMARY KEY (Id),
-> );

I am presented with this error:

ERROR 1064 (42000): 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 'Order (
CustomerId INTEGER NOT NULL,
EmployeeId INTEGE' at line 1

Any ideas?

Thank you :)

shriek
  • 21
  • 1

2 Answers2

0

Take the , off the end:

mysql> CREATE TABLE Order (                                                    
-> CustomerId INTEGER NOT NULL,                                                 
-> EmployeeId INTEGER,
-> Id INTEGER,
-> DT DATETIME(),
-> PRIMARY KEY (Id)
-> );
BarclayVision
  • 865
  • 2
  • 12
  • 41
-1

I think because Order is a keyword try wrapping it in []s, or pick another name.

  • `[]`s are not [MySql quote characters](https://dev.mysql.com/doc/refman/5.7/en/identifiers.html). – GSerg Mar 05 '17 at 10:45