I am trying to create a table with a timestamp field but am getting this error 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 'DEFAULT TIMESTAMP NOT NULL, start_time TIMESTAMP NOT NULL, end_time TIME' at line 3 I have tried DEFAULT CURRENT_TIMESTAMP but it didn't work. If anyone could help me out it would be great as I have tried searching for the problem but couldn't find anything.
CREATE TABLE appointment (
app_id int(5) NOT NULL AUTO_INCREMENT,
date_created DEFAULT CURRENT_TIMESTAMP NOT NULL,
start_time TIMESTAMP NOT NULL,
end_time TIMESTAMP NOT NULL,
client_id int(5),
price decmial(10,2),
cancelled tinyint(1),
treatment_id int(5) NOT NULL,
specialist_id int(5) NOT NULL,
PRIMARY KEY (client_id),
FOREIGN KEY (treatment_id) REFERENCES treatment(treatment_id),
FOREIGN KEY (client_id) REFERENCES client(client_id),
FOREIGN KEY (specialist_id) REFERENCES specialist(specialist_id)
) ENGINE=InnoDB;
date_created
has no type! And the not null fields need a default value
CREATE TABLE appointment (
app_id int(5) NOT NULL AUTO_INCREMENT,
date_created TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
start_time TIMESTAMP DEFAULT CURRENT_TIMESTAMPNOT NULL,
end_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
client_id int(5),
price decmial(10,2),
cancelled tinyint(1),
treatment_id int(5) NOT NULL,
specialist_id int(5) NOT NULL,
PRIMARY KEY (client_id),
FOREIGN KEY (treatment_id) REFERENCES treatment(treatment_id),
FOREIGN KEY (client_id) REFERENCES client(client_id),
FOREIGN KEY (specialist_id) REFERENCES specialist(specialist_id)
) ENGINE=InnoDB;