Log in

View Full Version : Making an sql table x2 error



keyboard
08-29-2011, 11:00 PM
Hi everyone,,,


CREATE TABLE jenChat_Users (
UserID int(10) unsigned NOT NULL auto_increment,
UserName varchar(20) NOT NULL default '',
LastUpdate timestamp(14) NOT NULL,
PRIMARY KEY (UserID)
);
CREATE TABLE jenChat_Messages (
MessageID int(10) unsigned NOT NULL auto_increment,
UserID int(10) unsigned NOT NULL default '0',
Posted timestamp(14) NOT NULL,
Message varchar(255) NOT NULL default '',
PRIMARY KEY (MessageID)
);

That code is causing this error




Error
SQL query:

CREATE TABLE jenChat_Users(

UserID int( 10 ) unsigned NOT NULL AUTO_INCREMENT ,
UserName varchar( 20 ) NOT NULL default '',
LastUpdatetimestamp( 14 ) NOT NULL ,
PRIMARY KEY ( UserID ) );



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 '(14) NOT NULL,
PRIMARY KEY (UserID)
)' at line 4





Any help would be great!

traq
08-29-2011, 11:20 PM
I've never defined a size for a TIMESTAMP column. In any case, 14 is too few characters for a mysql timestamp. just write `LastUpdate` TIMESTAMP NOT NULL.