问题
I am creating a database for my application. I get this error: MySQL said: Documentation
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 '(14) NOT NULL,
PRIMARY KEY (UserID))' at line 4 .
This is my sql statement:
CREATE TABLE sitheloChat_Users (
UserID int(10) unsigned NOT NULL auto_increment,
Username varchar(15) NOT NULL default '',
PreviousUpdate timestamp(14) NOT NULL,
PRIMARY KEY (UserID)
);
What must i add or edit?
回答1:
Remove the (14) from timestamp
mysql> CREATE TABLE sitheloChat_Users
( UserID int(10) unsigned NOT NULL auto_increment,
Username varchar(15) NOT NULL default '',
PreviousUpdate timestamp NOT NULL, PRIMARY KEY (UserID) );
Query OK, 0 rows affected (0.03 sec)
回答2:
TimeStamp doesn't need the length like String (varchar/varchar2).
CREATE TABLE sitheloChat_Users ( UserID int(10) unsigned NOT NULL auto_increment,
Username varchar(15) NOT NULL default '', PreviousUpdate timestamp NOT NULL,
PRIMARY KEY (UserID) );
来源:https://stackoverflow.com/questions/11362655/mysql-error-in-timestamp