我的sql脚本如下:
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`);
在mysql逗号行中提供它,发生错误信息。
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
如何修复我的sql脚本?
答案 0 :(得分:1)
您需要按照手册添加括号:
CREATE TABLE `stock_all` (
`state_dt` varchar(45),
`stock_code` varchar(45),
`open` decimal(20,2),
UNIQUE INDEX (`stock_code`),
PRIMARY KEY (`state_dt`)
);