Search code examples
mysqlcreate-table

Mysql Create Table error


Error SQL query:

CREATE TABLE Contacts(

Contact_ID INT NOT NULL ,
User VARCHAR NOT NULL ,
User_ID INT( 15 ) ,
PRIMARY KEY ( Contact_ID ) ,
FOREIGN KEY ( User_ID ) REFERENCES Users( User_ID )
)

MySQL said:

#1064 - 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 'NOT NULL,
User_ID int(15),
PRIMARY KEY (Contact_ID),
FOREIGN KEY (User_ID) RE' at line 4 

Solution

  • You need to supply the length of the VARCHAR field, like VARCHAR(64).