Reputation: 298
My sql script is as below:
CREATE database `stock`;
USE `stock`;
CREATE TABLE `stock_all` (
`state_dt` varchar(45),
`stock_code` varchar(45),
`open` decimal(20,2),
UNIQUE INDEX `stock_code`,
PRIMARY KEY `state_dt`);
source it in mysql commad line,an error info occurs.
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '
PRIMARY KEY `state_dt`)' at line 5
How to fix my sql script?
Upvotes: 0
Views: 150
Reputation: 1606
You'll need to add brackets as per manual:
CREATE TABLE `stock_all` (
`state_dt` varchar(45),
`stock_code` varchar(45),
`open` decimal(20,2),
UNIQUE INDEX (`stock_code`),
PRIMARY KEY (`state_dt`)
);
Upvotes: 1