gpt4 book ai didi

MySql 语法错误

转载 作者:行者123 更新时间:2023-11-29 08:59:45 28 4
gpt4 key购买 nike

我正在尝试为我下载的简单脚本创建这两个表,但在运行 sql 命令时它返回语法错误。

我得到的错误是:

CREATE TABLE `usrsig` (
`id` int(9) NOT NULL auto_increment,
`url` varchar(255) default NULL,
`user` int(9) NOT NULL default '0',
PRIMARY KEY (`id`)
KEY `user_own` (`user`)
);

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'KEY `user_own` (`user`) )' at line 6

第二个表的内容如下:

CREATE TABLE `usruser` (
`id` int(9) NOT NULL auto_increment,
`name` varchar(30) NOT NULL default '',
`pass` varchar(30) default NULL,
`last` datetime default NULL,
`hits` int(9) NOT NULL default '0',
PRIMARY KEY (`id`)
KEY `name_index` (`name`)
);

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'KEY `name_index` (`name`) )' at line 8

如果有人能帮助我,我将不胜感激。

谢谢

最佳答案

您只是在 PRIMARY KEY (id) 之后缺少一个逗号

CREATE TABLE `usrsig` (
`id` int(9) NOT NULL auto_increment,
`url` varchar(255) default NULL,
`user` int(9) NOT NULL default '0',
/* Comma needed... */
PRIMARY KEY (`id`),
KEY `user_own` (`user`)
);


CREATE TABLE `usruser` (
`id` int(9) NOT NULL auto_increment,
`name` varchar(30) NOT NULL default '',
`pass` varchar(30) default NULL,
`last` datetime default NULL,
`hits` int(9) NOT NULL default '0',
/* Comma needed... */
PRIMARY KEY (`id`),
KEY `name_index` (`name`)
);

作为提示,大约 99% 的情况下,MySQL 报告的错误恰好发生在所识别位置之前的一个字符。因此,请在 KEY name_index 之前查找一个字符或符号:

check the manual that corresponds to your MySQL server version for the right syntax to use near 'KEY name_index

关于MySql 语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8997571/

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