gpt4 book ai didi

SQL 不正确的表定义;只能有一个自动列,并且必须将其定义为键

转载 作者:行者123 更新时间:2023-12-02 17:38:16 24 4
gpt4 key购买 nike

如果我运行下面的 SQL 命令,我总是会收到此错误:

Invalid 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)) ; : Incorrect table definition; there can be only one auto column and it must be defined as a key

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,". 但这只会返回错误 multiple primary keys

最佳答案

我相信您的自动递增列(本身)一定是表的主键。

编辑

稍作阅读后,我认为它需要是任何类型的键,不一定是主键。

尝试添加“KEY(accountid)”或“UNIQUE KEY (accountid)”。

关于SQL 不正确的表定义;只能有一个自动列,并且必须将其定义为键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24087841/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com