2016-11-27 124 views
-1

我想打一個表中的phpmyadmin,我使用的SQL命令爲語法錯誤CREATE TABLE

CREATE TABLE userdetail( 
detailid INT(255) UNSIGNED AUTO_INCREMENT PRIMARY, 
name varchar(255) NOT NULL, 
address text, 
phone varchar(13) NOT NULL, 
email_id varchar(255), 
userId int(20) NOT NULL, 
reg_date TIMESTAMP 
) 

我收到此錯誤:

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 ' name varchar(255) NOT NULL, address text, phone varchar(13) NOT ' at line 2

+0

'PRIMARY KEY'並不僅僅是'PRIMARY' –

回答

1

它應該是這樣的

CREATE TABLE userdetail( 
    detailid INT(255) UNSIGNED AUTO_INCREMENT PRIMARY KEY, 
    name varchar(255) NOT NULL, 
    address text, 
    phone varchar(13) NOT NULL, 
    email_id varchar(255), 
    userId int(20) NOT NULL, 
    reg_date TIMESTAMP); 
0

你失蹤KEYPRIMARY

CREATE TABLE userdetail ( 
    detailid INT(255) UNSIGNED AUTO_INCREMENT PRIMARY KEY, 
    name varchar(255) NOT NULL, 
    address text, 
    phone varchar(13) NOT NULL, 
    email_id varchar(255), 
    userId int(20) NOT NULL, 
    reg_date TIMESTAMP 
) 

注意int(255)真的沒有本質NSE。您是否熟悉整數數據類型以及括號中的值是什麼意思?您可以查看文檔here

+0

有沒有爲downvote原因?答案看起來正確。 –

相關問題