Sithelo
Sithelo

Reputation: 307

MySQL error in timestamp

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?

Upvotes: 0

Views: 6091

Answers (2)

manurajhada
manurajhada

Reputation: 5380

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) );

Upvotes: 1

jcho360
jcho360

Reputation: 3759

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)

Upvotes: 3

Related Questions