[英]Error 1064 when running CREATE TABLE script
I am trying to run a SQL script to add tables to my database and keep getting error 1064. Here is the code: 我试图运行一个SQL脚本以将表添加到我的数据库中,并不断收到错误1064。这是代码:
CREATE TABLE 'Bookings' (
'Booking_id' INTEGER(10) NOT NULL AUTO_INCREMENT,
'Arrival_Date' date(8) CURRENT_TIMESTAMP NOT NULL,
'Departure_Date' date(8) CURRENT_TIMESTAMP NOT NULL,
'Registrants_ID' INTEGER(10) DEFAULT NOT NULL,
'Accomodation_ID' INTEGER(10) DEFAULT NOT NULL,
PRIMARY KEY ('Booking_ID'),
KEY 'Accomodation_ID' ('Accomodation_ID'),
KEY 'Registrants_ID' ('Registrants_ID'),
CONSTRAINT 'bookings_ibfk_1' FOREIGN KEY ('Accomodation_ID') REFERENCES 'Accommodation' ('Accomodation_ID')
CONSTRAINT 'bookings_ibfk_2' FOREIGN KEY ('Registrants_ID') REFERENCES 'Registrants' ('Registrants_ID')
);
尝试删除列名称中的'。
You should use datetime for Arrival_Date etc, 您应该将datetime用于Arrival_Date等,
current_timestamp give : 2015-02-18 15:34:24
current_timestamp给:
2015-02-18 15:34:24
current_date: 2015-02-18
当前日期:
2015-02-18
You need to provide a default value if you specify DEFAULT
. 如果指定
DEFAULT
则需要提供一个默认值。
Eg 例如
'Registrants_ID' INTEGER(10) DEFAULT 1 NOT NULL,
'Accomodation_ID' INTEGER(10) DEFAULT 1 NOT NULL,
Also you should be using backticks ( ` ) instead of single quotes ( ' ) around field/table/index names. 另外,您应该在字段/表/索引名称周围使用反引号(`)而不是单引号(')。
Also you cannot make a date field default to CURRENT_TIMESTAMP
. 同样,您不能将日期字段默认设置为
CURRENT_TIMESTAMP
。 And if you want a timestamp field to default to CURRENT_TIMESTAMP
, you need the DEFAULT
keyword. 并且,如果您希望时间戳字段默认为
CURRENT_TIMESTAMP
,则需要DEFAULT
关键字。 eg: DEFAULT CURRENT_TIMESTAMP
例如:
DEFAULT CURRENT_TIMESTAMP
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.