简体   繁体   中英

SQL error #1064 on CREATE TABLE

I am importing a database from MySQL 4.0.27-standard into a new webhost with Server version: 5.5.48-37.8 - Percona Server (GPL), Release 37.8, Revision 727, using PHPMySQL.

I am getting the following error:

#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 (site_id) ) ENGINE=MyISAM' at line 14

Here is the CREATE TABLE query:

CREATE TABLE Brewing (
  site_id int(5) NOT NULL auto_increment,
  site_url varchar(255) NOT NULL default '',
  site_name varchar(255) NOT NULL default '',
  site_comment varchar(255) default NULL,
  site_rating int(2) NOT NULL default '0',
  site_entrydate varchar(25) NOT NULL default '',
  site_lasttouched timestamp(14) NOT NULL,
  PRIMARY KEY  (site_id)
) ENGINE=MyISAM;

Remove the size of timestamp . It already has a default for setting up timestamp. So remove (14). Plus added bonus, add ON UPDATE CURRENT_TIMESTAMP for auto update of timestamp .

The length argument for timestamp represents fractional seconds (see the documentation ). The allowed lengths for fractional seconds are 0 to 6. 14 is too long.

I would advise you to just remove the length altogether.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM