2013-11-25 52 views
0

那么,我已经有一段时间了,需要一些帮助。谢谢!在MySQL 5.6中现在使用“()”的正确语法是什么?

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. 

回答

3

错位括号,尝试

DEFAULT now(), 

但你想现在的INT列默认也许对于timestamp列,在这种情况下,你做的?

Created TIMESTAMP DEFAULT CURRENT_TIMESTAMP, 

看看这里即使该字段是日期时间,您仍然无法将其默认设置为NOW。

Docs

+1

一个'INT'字段,称为'Subject',默认为'NOW()'。嗯... – OGHaza

+0

@OGHaza我的错误我认为现在糟糕的是指前一列,OP没有公布整个交易。现在没有下一个现在是好的。 – Mihai

相关问题