现在在mysql 5.6中使用'()附近的正确语法是什么?

时间:2013-11-25 20:56:08

标签: mysql

好吧,我已经有一段时间了,需要一些帮助。谢谢!

ERROR: 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 '() now,

  `Body` TEXT NULL,

  `Created` TIMESTAMP NULL COMMENT 'This descrbes th' at line 2



CREATE TABLE IF NOT EXISTS `Newsletters` (

  `Subject` INT NOT NULL DEFAULT () now,

  `Body` TEXT NULL,

  `Created` TIMESTAMP NULL COMMENT 'This descrbes the newsletter.',

  PRIMARY KEY (`Subject`))

ENGINE = InnoDB



SQL script execution finished: statements: 36 succeeded, 1 failed



Fetching back view definitions in final form.

Could not get definition for ABC_Blue.view1 from server

1 views were read back.

1 个答案:

答案 0 :(得分:3)

错位的parantheses,试试

 DEFAULT now(),

但是你现在想要INT列的默认值吗?也许对于timestamp列,在这种情况下你可以:

Created TIMESTAMP DEFAULT CURRENT_TIMESTAMP,

即使该字段是日期时间,请查看此处,您仍然无法将其默认设置为现在。

Docs