phpMyAdmin4.4.1导出的数据库脚本
DROP TABLE IF EXISTS `xx_ad`; CREATE TABLE IF NOT EXISTS `xx_ad` ( `id` bigint(20) NOT NULL auto_increment, `create_date` datetime NOT NULL, `modify_date` datetime NOT NULL, `orders` int(11) default NULL, `begin_date` datetime default NULL, `content` longtext, `end_date` datetime default NULL, `path` varchar(255) default NULL, `title` varchar(255) NOT NULL, `type` int(11) NOT NULL, `url` varchar(255) default NULL, `ad_position` bigint(20) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
MySQL workbench执行时,报错“Error Code: 1075. Incorrect table definition; there can be only one auto column and it must be defined as a key
”
解决方案
10
少了主键定义。
30
确实是兼容性导致的问题,在5.0不需要innodb的表的自增列一定要主键,而现在是一定要主键了
mysql> create table tt(i int auto_increment ) engine = innodb;
ERROR 1075 (42000): Incorrect table definition; there can be only one auto column and it must be defined as a key
mysql> create table tt(i int auto_increment primary key) engine = innodb;
Query OK, 0 rows affected (3.50 sec)