2015-05-29 105 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版本,或者您可以使用查詢如上。