2016-08-24 169 views
1

//請任何人都可以告訴我這個MySQL查詢語法有什麼問題?mySQL表創建查詢語法錯誤

String createTableSQL = "" 
       + " CREATE TABLE location(" 
       + " location_id INTEGER PRIMARY KEY AUTOINCREMENT," 
       + " location_name VARCHAR(30)," 
       + " addr VARCHAR(30)," 
       + ")"; 

回答

1

刪除最後一個變化AUTOINCREMENT在AUTO_INCREMENT並添加PRIMARY KEY(location_id

String createTableSQL = "" 
      + " CREATE TABLE location(" 
      + " location_id INTEGER PRIMARY KEY AUTO_INCREMENT," 
      + " location_name VARCHAR(30)," 
      + " addr VARCHAR(30)," 
      + " PRIMARY KEY (`location_id `))"; 
+0

我刪除了,也許我有一些錯誤,因此並沒有在這個時候幫助。 –

+0

@MartaGinosian AUTO_INCREMENT - 需要'_' !!! – Mike

+0

太好了,謝謝@Mike。它幫助,桌子被創造。 –