我正在尝试使用下面的代码在数据库中创建一个tabe。但是,它不起作用,我无法弄清楚原因。
生成的错误是'UNIQUE KEY ID (ID)'
上的语法错误,但根据我正在使用的教程(以及我能找到的文档),看起来没问题。
我还尝试了'UNIQUE ID (ID)'
和'UNIQUE ID'
,但我仍然遇到语法错误。
CREATE TABLE wp_offices (
ID smallint(3) NOT NULL AUTO_INCREMENT,
office_created_by smallint(3) DEFAULT "0",
office_created_date datetime DEFAULT "0000-00-00 00:00:00" NOT NULL,
office_last_edited_by smallint(3) DEFAULT "0",
office_last_edited_date datetime DEFAULT "0000-00-00 00:00:00" NOT NULL,
office_name tinytext COLLATE latin1_general_ci,
address_1 tinytext COLLATE latin1_general_ci,
address_2 tinytext COLLATE latin1_general_ci,
town tinytext COLLATE latin1_general_ci,
county tinytext COLLATE latin1_general_ci,
postcode tinytext COLLATE latin1_general_ci,
telephone tinytext COLLATE latin1_general_ci,
fax tinytext COLLATE latin1_general_ci,
dx tinytext COLLATE latin1_general_ci,
email tinytext COLLATE latin1_general_ci,
google_maps text(256) COLLATE latin1_general_ci
)
UNIQUE KEY ID (ID);
有人可以告诉我我做错了什么吗?感谢。
答案 0 :(得分:4)
它应该在大括号内
google_maps text(256) COLLATE latin1_general_ci,
UNIQUE KEY ID (ID)
);
答案 1 :(得分:2)
创建表格的代码将是
CREATE TABLE wp_offices(
ID SMALLINT( 3 ) NOT NULL AUTO_INCREMENT ,
office_created_by SMALLINT( 3 ) DEFAULT "0",
office_created_date DATETIME DEFAULT "0000-00-00 00:00:00" NOT NULL ,
office_last_edited_by SMALLINT( 3 ) DEFAULT "0",
office_last_edited_date DATETIME DEFAULT "0000-00-00 00:00:00" NOT NULL ,
office_name TINYTEXT COLLATE latin1_general_ci,
address_1 TINYTEXT COLLATE latin1_general_ci,
address_2 TINYTEXT COLLATE latin1_general_ci,
town TINYTEXT COLLATE latin1_general_ci,
county TINYTEXT COLLATE latin1_general_ci,
postcode TINYTEXT COLLATE latin1_general_ci,
telephone TINYTEXT COLLATE latin1_general_ci,
fax TINYTEXT COLLATE latin1_general_ci,
dx TINYTEXT COLLATE latin1_general_ci,
email TINYTEXT COLLATE latin1_general_ci,
google_maps TEXT( 256 ) COLLATE latin1_general_ci,
UNIQUE KEY ID( ID )
);