创建表语法错误 [英] Create Table Syntax Error

查看:92
本文介绍了创建表语法错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到一个MySQL数据转储,并试图将数据插入一组临时表中.第一个表的创建语句如下所示.运行此命令时,出现错误:"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 ''temp_books'( 'ID'int( 11 ) NOT NULL AUTO_INCREMENT, 'start'varchar( 20 ) ' at line 1".我检查了MySQL语法的文档,但没有发现问题所在.

I received a MySQL data dump and am trying to insert the data into a set of temporary tables. The creation statement for the first table is shown below. When I run this I receive the error: "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 ''temp_books'( 'ID'int( 11 ) NOT NULL AUTO_INCREMENT, 'start'varchar( 20 ) ' at line 1". I've checked the documentation for MySQL syntax, and I don't see that the problem is.

CREATE TABLE 'temp_books' (
  'ID' int(11) NOT NULL AUTO_INCREMENT,
  'start' varchar(20) NOT NULL,
  'customer_id' int(11) NOT NULL DEFAULT '0',
  'total_num' int(11) NOT NULL,
  'amount' double(5,2) NOT NULL DEFAULT '0.00',
  'changed' timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY ('ID'),
  UNIQUE KEY 'start' ('start')
) ENGINE=MyISAM AUTO_INCREMENT=4853 DEFAULT CHARSET=latin1;

推荐答案

您不应在标识符上加上单引号.如果要引用它们,请使用"back tick"字符(`").您也可以使用双引号,但必须指定该模式:

You shouldn't put single-quotes on your identifiers. If you're going to quote them use the "back tick" character ("`"). You can also use double-quotes but you have to specify that mode:

SET sql_mode='ANSI_QUOTES';

http://dev.mysql.com/doc/refman/5.0/zh-CN/identifiers.html

这篇关于创建表语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆