USE Airline;
CREATE TABLE Responsible_for(
Time_work TIME NOT NULL,
date_work DATE NOT NULL,
Staff_ID INT NOT NULL,
Passenger_ID VARCHAR(45) NOT NULL,
CONSTRAINT FOREIGN KEY(Passenger_ID) REFERENCES Passenger(Passenger_ID),
CONSTRAINT FOREIGN KEY(Staff_ID) REFERENCES Staff(Staff_ID));
SELECT * FROM airline.Responsible_for;
INSERT INTO Responsible_for VALUES(
('04:00:00','2019-04-01',1235,'1102546778'));
why there is error? thank you
You have an additional pair of parentheses around the list of values that should not be there.
That should be:
INSERT INTO Responsible_for(time_work, date_work, staff_id, passenger_id)
VALUES ('04:00:00','2019-04-01',1235,'1102546778');
Notes:
it is a good practice to always enumerate the columns to insert
; this prevents hard-to-debug issues, and can make the code resilient to changes in the structure of the target table
you use airline
at the beginning of the script, so there is no need to prefix the table name with the schema name in the insert
statement
I would recommend against storing the date and time components in separate columns; this makes things unnecessarily complicated (and less efficient) when you need to compare it against a datetime; MySQL has the datetime
datatype, that is meant to store both together
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.