开发者

Why can't I use Current_timestamp as default value in mysql?

I has a MySQL database set up locally with phpmyadmin. I wanted to use the available tables in a remote database, so I exported the SQL from phpmyadmin and tried to run it on the other DB.

This is what the export gave me:

CREATE TABLE IF NOT EXISTS `messages` (
  `ID` int(11开发者_如何转开发) NOT NULL AUTO_INCREMENT,
  `Title` varchar(255) NOT NULL,
  `Message` text NOT NULL,
  `MsgType` varchar(10) DEFAULT NULL,
  `Important` int(1) NOT NULL DEFAULT '0',
  `Poster` int(5) DEFAULT NULL,
  `Date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=37 ;

However, now it complains that there is a parse error

near 'CURRENT_TIMESTAMP, PRIMARY KEY (ID) ) ENGINE=MyISAM DEFA".

It worked on my local db, why not here? What changed and how do I fix it?

EDIT: I've tried using other functions like NOW() or CURDATE() as well, same problem.


From the documentation:

Note In older versions of MySQL (prior to 4.1), the properties of the TIMESTAMP data type differed significantly in several ways from what is described in this section (see the MySQL 3.23, 4.0, 4.1 Reference Manual for details); these include syntax extensions which are deprecated in MySQL 5.1, and no longer supported in MySQL 5.5. This has implications for performing a dump and restore or replicating between MySQL Server versions.

MySQL 4.0.24 is incredibly outdated, at this point - consider migrating to a version that starts with a 5. :-)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜