Reputation: 11
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
Upvotes: 0
Views: 6581
Reputation: 149
//delete all
Drop-Database
Remove-Migration
Remove-Migration
Remove-Migration until you clear all migration
Add-Migration
Update-Database
Upvotes: 0
Reputation: 4017
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)
);
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)
);
Upvotes: 0
Reputation: 15333
The way you are putting Primary key and other key is the syntax problem.
Primary Key (id),
Put a comma after this.
Upvotes: 0
Reputation: 11915
I think you are just missing a comma after the PRIMARY KEY ('id') line.
Upvotes: 0
Reputation: 270607
You're just missing a comma after 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`)
);
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
:
check the manual that corresponds to your MySQL server version for the right syntax to use near 'KEY
name_index
Upvotes: 2