php phpmyadmin #1075 - 不正确的表定义;只能有一个自动列,并且必须将其定义为键
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20310626/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Phpmyadmin #1075 - Incorrect table definition; there can be only one auto column and it must be defined as a key
提问by Nimara
Hi, I'm importing mySql database (which was originally an access database) into phpmyadmin and its giving me this error:
嗨,我正在将 mySql 数据库(最初是一个访问数据库)导入到 phpmyadmin 中,它给了我这个错误:
SQL query:
SQL查询:
CREATE TABLE `Acc_inst` (
`inst_ID` INTEGER NOT NULL AUTO_INCREMENT ,
`inst_Name` VARCHAR( 255 ) ,
`Inst_Ws` VARCHAR( 255 ) ,
`inst_ph` VARCHAR( 255 ) ,
`inst_Fx` VARCHAR( 255 ) ,
`Inst_E` VARCHAR( 255 )
) ENGINE = INNODB DEFAULT CHARSET = utf8;
MySQL said: Documentation
MySQL 说: 文档
1075 - Incorrect table definition; there can be only one auto column and it must be defined as a key
1075 - 不正确的表定义;只能有一个自动列,并且必须将其定义为键
-- There is in fact only on auto increment column and it is defined as a primary key so I dont get why its giving me this error
-- 实际上只有在自动增量列上,它被定义为主键,所以我不明白为什么它给我这个错误
采纳答案by Tarun
Define your auto increment column as a primary key.
将您的自动增量列定义为主键。
CREATE TABLE `Acc_inst`
(
`inst_ID` INTEGER NOT NULL AUTO_INCREMENT ,
`inst_Name` VARCHAR( 255 ) ,
`Inst_Ws` VARCHAR( 255 ) ,
`inst_ph` VARCHAR( 255 ) ,
`inst_Fx` VARCHAR( 255 ) ,
`Inst_E` VARCHAR( 255 ) ,
PRIMARY KEY `inst_ID`(`inst_ID`)
) ENGINE = INNODB DEFAULT CHARSET = utf8;
回答by AdrianC
A bit late, but i'm getting the same error in the latest version of phpMyAdmin (4.4.2). Nimara used manual SQL query, i used the special "add new table" form and still got this error.
有点晚了,但我在最新版本的 phpMyAdmin (4.4.2) 中遇到了同样的错误。Nimara 使用了手动 SQL 查询,我使用了特殊的“添加新表”表单,但仍然出现此错误。
So, for those of you that got here just like me, searching the #1075 error, you should know that this happens if you set your index / primary / autoincrement column in the form at first, then added some new columns and then wanted to submit the form. It seems that when you add more columns, phpMyAdmin does some kind of background refresh and loses the "primary" information. You still see it in your form, but in the background the SQL query it sends does not have this info any more.
所以,对于那些像我一样来到这里的人,搜索 #1075 错误,你应该知道如果你首先在表单中设置索引/主/自动增量列,然后添加一些新列然后想要提交表格。似乎当您添加更多列时,phpMyAdmin 会进行某种后台刷新并丢失“主要”信息。您仍然可以在表单中看到它,但在后台它发送的 SQL 查询不再包含此信息。
So the solution would be to deselect your primary column and set it again. I'm pretty sure it's a bug, but it solves simple and fast this way.
因此,解决方案是取消选择主列并重新设置。我很确定这是一个错误,但它以这种方式解决简单快捷。
回答by juergen d
CREATE TABLE `Acc_inst`
(
`inst_ID` INTEGER NOT NULL primary key AUTO_INCREMENT ,
`inst_Name` VARCHAR( 255 ) ,
`Inst_Ws` VARCHAR( 255 ) ,
`inst_ph` VARCHAR( 255 ) ,
`inst_Fx` VARCHAR( 255 ) ,
`Inst_E` VARCHAR( 255 )
) ENGINE = INNODB DEFAULT CHARSET = utf8;
The error says you must define an auto increment column as key: Add primary keyto this column definition.
错误说您必须将自动增量列定义为键:添加primary key到此列定义。

