2012-09-22 65 views
-2

這裏我們再次去。 MySQL拋出這個錯誤:#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 'tinytext not null, FirstName varchar(50) not null, LastName varchar(50) nu' at line 5MySQL錯誤#1064再次

這可能是什麼語法問題?

下面的代碼:

CREATE TABLE posts (
     ID int unsigned not null auto_increment, 
     Type enum('article', 'link') not null, 
     Title text null, 
     Link text null, 
     BodyOrig longtext null, 
     BodyProc longtext not null, 
     URL tinytext not null, 
     ShortURL tinytext not null, 
     Status enum('drafted', 'published') not null, 
     DateEdited timestamp null, 
     DatePublished timestamp null, 
     Topic enum('') null, 

     primary key (ID, URL(255), ShortURL(10)) 
    ); 
    CREATE TABLE pages (
     ID int unsigned not null auto_increment, 
     Name varchar(25) not null, 
     Title text not null, 
     BodyOrig longtext null, 
     BodyProc longtext not null, 
     URL tinytext not null, 
     Hero text null, 
     Status enum('drafted', 'published') not null, 

     primary key (ID, Name, URL(255)) 
    ); 
    CREATE TABLE users (
     ID int unsigned not null auto_increment, 
     Username varchar(25) not null, 
     Password text not null, 
     Key tinytext not null, 
     FirstName varchar(50) not null, 
     LastName varchar(50) null, 
     DisplayName tinytext not null, 
     Email tinytext not null, 

     primary key (ID, Username, Key(255)); 
    ); 
    CREATE TABLE settings (
     Version varchar(10) not null, 
     SiteName tinytext not null, 
     Description tinytext not null, 
     ColorScheme char(6) not null 
    ); 

,要麼是我的眼睛,沒有在他們的最佳狀態,或有一些(具體格式?)我失蹤。非常感謝您的幫助!

+0

[由於在MySQL中使用保留字作爲表或列名而導致的語法錯誤]的可能重複(http://stackoverflow.com/questions/23446377/syntax-error-due-to-using-a-reserved -word-as-a-table-or-column-name-in-mysql) –

回答

4

您正在嘗試創建一個名爲「Key」的列,該列是reserved keyword

+0

謝謝。這工作好一點。現在我明白了。 '#1064 - 你的SQL語法有錯誤;檢查與您的MySQL服務器版本相對應的手冊,在第11行''附近使用正確的語法' –

+1

嘗試轉義所有實體 - 'tableName','field'名稱。 – adatapost

+0

這意味着什麼? (對不起,此處總共有noob。) –