gpt4 book ai didi

mysql - 导入schema.sql时出错

转载 作者:行者123 更新时间:2023-11-29 12:04:24 26 4
gpt4 key购买 nike

我是 sql 新手,目前我通过 XAMP 使用 phpMyAdmin,我认为它使用 mysql,所以如果我说错了,请纠正我。不管怎样,我正在尝试将 schema.sql 数据文件导入到我创建的名为“test”的数据库中,但导入时出现错误:

它说

Import has been successfully finished, 1 queries executed. (schema.sql)

但是它也给了我一条错误消息:

CREATE TABLE `population` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`location` varchar(150) NOT NULL,
`slug` varchar(150) NOT NULL,
`population` int(10) unsigned NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8
MySQL said: Documentation

1075 - Incorrect table definition; there can be only one auto column and it must be defined as a key

和:

Notice in .\import.php#704 Undefined variable: import_text Backtrace

我不确定问题是什么。我创建的数据库是完整的,里面什么也没有。

最佳答案

Column id 是有问题的自动列;自动列需要定义为键,例如唯一键或主键。就您而言,主键是一个好主意,因为 - 嗯,它是您的 id 列。

CREATE TABLE `population` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`location` varchar(150) NOT NULL,
`slug` varchar(150) NOT NULL,
`population` int(10) unsigned NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8

关于mysql - 导入schema.sql时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31792331/

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