我是使用MYSQL的新手,找不到语法错误

时间:2019-08-02 19:09:38

标签: mysql sql

我一直收到语法错误,但是我是SQL的新手,在查找错误时遇到了麻烦。我已经阅读了多篇文章,没有运气解决问题

CREATE TABLE 'stock_prices' (
'price_date' DATE NOT NULL,    
'minute_time' DATETIME NOT NULL,
'ticker' VARCHAR(20) NOT NULL,
'open_price' DECIMAL(15,6) NULL DEFAULT NULL,
'high_price' DECIMAL(15,6) NULL DEFAULT NULL,
'low_price' DECIMAL(15,6) NULL DEFAULT NULL,
'close_price' DECIMAL(15,6) NULL DEFAULT NULL,                                  
'total_volume' BIGINT(20) NOT NULL,                                             
'total_quantity' INT(11) NULL DEFAULT NULL,                                     
'total_trade_count' INT(11) NOT NULL,                                           
PRIMARY KEY ('ticker'))ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

错误:

ERROR 1064 (42000): 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 ''stock_data' ( 'price_date' DATE NOT NULL,
'minute_time' DATETIME NOT NULL,
'tic' at line 1

1 个答案:

答案 0 :(得分:2)

更改引号:

CREATE TABLE stock_prices ( `price_date` DATE NOT NULL, 
  `minute_time` DATETIME NOT NULL,
  `ticker` VARCHAR(20), 
  `open_price` DECIMAL(15,6) NULL DEFAULT NULL,
  `high_price` DECIMAL(15,6) NULL DEFAULT NULL,
  `low_price` DECIMAL(15,6) NULL DEFAULT NULL,
  `close_price` DECIMAL(15,6) NULL DEFAULT NULL,
  `total_volume` BIGINT(20) NOT NULL,
  `total_quantity` INT(11) NULL DEFAULT NULL,
  `total_trade_count` INT(11) NOT NULL, 
  PRIMARY KEY (`ticker`)) 
ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;