2015-05-29 106 views
0

我的查询似乎是确定的:就我所知有云:无法解决MySQL错误#1064

CREATE TABLE PORTAL_NOTES (
    id numeric NOT NULL, 
    school_id numeric, 
    syear numeric(4,0), 
    title character varying(255), 
    content character varying(5000), 
    sort_order numeric, 
    published_user numeric, 
    published_date timestamp(0), 
    start_date date, 
    end_date date, 
    published_profiles character varying(255) 
); 

但我得到这个错误:

#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 '(1) , start_date date, end_date date, published_profiles characte' at line 9 

谁能帮我调试问题在这里?

+0

'timestamp'不需要长度。 –

+1

适合我! http://sqlfiddle.com/#!9/161c6 –

+0

就在我头顶,不应该只是时间戳,而不是时间戳(0)? – Endareth

回答

0

试试这个:

CREATE TABLE PORTAL_NOTES (
    id numeric NOT NULL, 
    school_id numeric, 
    syear numeric(4,0), 
    title character varying(255), 
    content character varying(5000), 
    sort_order numeric, 
    published_user numeric, 
    published_date timestamp, 
    start_date date, 
    end_date date, 
    published_profiles character varying(255) 
); 

问题是因为你在timestamp(0)设置长度,这并不需要的长度。

+0

但是,如果您提供一个 – Strawberry

+1

服务器,则在5.6之前的服务器版本可能会阻塞一个长度,即使为0也是没有区别的,因为在5.6之前不支持长度。 –

0
CREATE TABLE PORTAL_NOTES (
    id numeric NOT NULL, 
    school_id numeric, 
    syear numeric(4,0), 
    title character varying(255), 
    content character varying(5000), 
    sort_order numeric, 
    published_user numeric, 
    published_date timestamp, 
    start_date date, 
    end_date date, 
    published_profiles character varying(255) 
); 

使用上面的代码.. 我想你的MySQL版本较低,所以它不支持长.. 更新MySQL版本,或者您可以使用查询如上。