Reputation: 3
I've looked at previous posts but I am struggling to figure out where i am going wrong. I am trying to create a table using this code:
mysql> CREATE TABLE Engine
-> (
-> ID VARCHAR(255) UNASSSIGNED NOT NULL AUTO_INCREMENT UNIQUE,
-> Name VARCHAR(255) NOT NULL,
-> Displacement VARCHAR(10) NOT NULL,
-> Code VARCHAR(10) NOT NULL,
-> PowerOutput VARCHAR(10),
-> MadeAt VARCHAR(255) NOT NULL,
-> PRIMARY KEY (ID),
-> FOREIGN KEY (MadeAt)
-> );
However I am repeatedly getting 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 'UNASSSIGNED NOT NULL AUTO_INCREMENT UNIQUE,
Name VARCHAR(255) NOT NULL, Displace' at line 3
Any help would be much appreciated.
Upvotes: 0
Views: 139
Reputation: 8729
Try to change
ID VARCHAR(255) UNASSSIGNED NOT NULL AUTO_INCREMENT UNIQUE
into:
ID INT NOT NULL AUTO_INCREMENT
UNASSIGNED
should be UNSIGNED
, but it is not necessary to define this, because AUTO_INCREMENT
will start at 1
by default when not defined otherwise. UNIQUE
is redundant as well, because the ID will increment and the numbers will be unique anyway.
In most cases VARCHAR
is not recommended to use as PRIMARY KEY
.
Upvotes: 2