MySql 语法错误
我正在尝试为我下载的简单脚本创建这两个表,但在运行 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
如果有人能好心地帮助我,我将非常感激。
谢谢
I am trying to create these two tables for a simple script I downloaded but when running the sql command it returns a syntax error.
The error I get is:
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
And the following for the 2nd tabel:
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
If anyone could be so kind as to help me out I would be greatly appreciative.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您只是在
PRIMARY KEY (id)
之后缺少一个逗号。提示一下,大约 99% 的情况下,MySQL 报告的错误恰好出现在所标识位置之前的一个字符。因此,请在
KEY name_index
之前查找一个字符或符号:You're just missing a comma after
PRIMARY KEY (id)
As a tip, about 99% of the time, the error as reported by MySQL occurs exactly one character before the place identified. So look one character or symbol before
KEY name_index
:我认为您只是在 PRIMARY KEY ('id') 行后面缺少一个逗号。
I think you are just missing a comma after the PRIMARY KEY ('id') line.
您放置主键和其他键的方式是语法问题。
主键 (id),
在其后面放置一个逗号。
The way you are putting Primary key and other key is the syntax problem.
Primary Key (id),
Put a comma after this.
任何主键错误 - 修复
//删除所有
Drop-Database
删除迁移
删除迁移
删除迁移
直到清除所有迁移
Add-Migration
更新数据库
成功
Any primary key error - fix
//delete all
Drop-Database
Remove-Migration
Remove-Migration
Remove-Migration
until you clear all migration
Add-Migration
Update-Database
success