Reputation: 115
I am trying to run a SQL script to add tables to my database and keep getting error 1064. Here is the code:
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')
);
Upvotes: 0
Views: 78
Reputation: 11084
You need to provide a default value if you specify DEFAULT
.
E.g.
'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
. And if you want a timestamp field to default to CURRENT_TIMESTAMP
, you need the DEFAULT
keyword. e.g.: DEFAULT CURRENT_TIMESTAMP
Upvotes: 0
Reputation: 11
You should use datetime for Arrival_Date etc,
current_timestamp give : 2015-02-18 15:34:24
current_date: 2015-02-18
Upvotes: 0