如果我在下面运行SQL命令,我总是会收到此错误:
无效的SQL:CREATE TABLE ms_account(accountid INT NOT NULL auto_increment,accountname VARCHAR(50)NOT NULL,kindofaccount SMALLINT NOT NULL,accountowner VARCHAR(20)NOT NULL,accountcurrency VARCHAR(10)NOT NULL,accountbalance DECIMAL(15, 2)NOT NULL,bankid VARCHAR(8)NOT NULL,createdate INT NOT NULL,deletedate INT NOT NULL,changedate INT NOT NULL,deleted SMALLINT NOT NULL,locked SMALLINT NOT NULL,PRIMARY KEY accountid(bankid,accountid)); :表定义不正确;只能有一个自动列,必须将其定义为键
SQL
"CREATE TABLE {$utcv_db_prefix}account (".
"accountid INT NOT NULL auto_increment,".
"accountname VARCHAR(50) NOT NULL,".
"kindofaccount SMALLINT NOT NULL,".
"accountowner VARCHAR(20) NOT NULL,".
"accountcurrency VARCHAR(10) NOT NULL,".
"accountbalance DECIMAL(15,2) NOT NULL,".
"bankid VARCHAR(8) NOT NULL,".
"createdate INT NOT NULL,".
"deletedate INT NOT NULL,".
"changedate INT NOT NULL,".
"deleted SMALLINT NOT NULL,".
"locked SMALLINT NOT NULL,".
"PRIMARY KEY (bankid,accountid)".
") $utcv_db_create_extension;";
我已经尝试将主键添加到"accountid INT NOT NULL auto_increment,".
,但只返回错误多个主键
答案 0 :(得分:3)
我相信你的自动增量列(本身)必须是表的主键。
修改强>
在做了一点阅读之后,我认为它需要是任何类型的键,不一定是主键。
尝试添加“KEY(accountid)”或“UNIQUE KEY(accountid)”。