|
Помогите с решением задачи
|
|||
---|---|---|---|
#18+
Создал 3 базы данных, но при попытке сделать любой запрос к ним выдает ошибку Базы данных: CREATE TABLE pilots (pilot_id INT PRIMARY KEY AUTO_INCREMENT, name VARCHAR(50), age INT, rang int, education_level VARCHAR(50) ); CREATE TABLE planes (plane_id INT PRIMARY KEY AUTO_INCREMENT, capacity INT, cargo_flg INT); CREATE TABLE flights (flight_id INT PRIMARY KEY AUTO_INCREMENT, flight_dt DATE, plane_id INT, first_pilot_id INT, second_pilot_id INT, destination VARCHAR(50), quantity INT, FOREIGN KEY (plane_id) REFERENCES planes(plane_id), FOREIGN KEY (first_pilot_id) REFERENCES pilots (pilot_id), FOREIGN KEY (second_pilot_id) REFERENCES pilots (pilot_id) ); Наполнение: INSERT INTO pilots (name, age, rang, education_level) VALUES ('Egor',54,2,"Sharaga"); INSERT INTO pilots (name, age, rang, education_level) VALUES ('Pozhiloy',228,1,"Sharaga"); INSERT INTO planes (capacity,cargo_flg) VALUES (1488,1); INSERT INTO planes (capacity,cargo_flg) VALUES (666,0); INSERT INTO flights (flight_dt,plane_id,first_pilot_id,second_pilot_id,destination,quantity) VALUES ("2021-08-14",1,1,2,'Шереметьево',1488); INSERT INTO flights (flight_dt,plane_id,first_pilot_id,second_pilot_id,destination,quantity) VALUES ("2020-08-14",0,1,2,'Шереметьево',666); Ошибка(компилятор на stepik.org): ERROR 1452: Cannot add or update a child row: a foreign key constraint fails (`stepik_7aVnZy0P`.`flights`, CONSTRAINT `flights_ibfk_1` FOREIGN KEY (`plane_id`) REFERENCES `planes` (`plane_id`)) ... |
|||
:
Нравится:
Не нравится:
|
|||
22.08.2021, 21:23 |
|
Помогите с решением задачи
|
|||
---|---|---|---|
#18+
hector183 INSERT INTO flights (flight_dt,plane_id,first_pilot_id,second_pilot_id,destination,quantity) VALUES ("2020-08-14", 0 ,1,2,'Шереметьево',666); ... |
|||
:
Нравится:
Не нравится:
|
|||
22.08.2021, 21:55 |
|
|
start [/forum/topic.php?fid=47&fpage=6&tid=1827975]: |
0ms |
get settings: |
12ms |
get forum list: |
16ms |
check forum access: |
4ms |
check topic access: |
4ms |
track hit: |
86ms |
get topic data: |
11ms |
get forum data: |
3ms |
get page messages: |
46ms |
get tp. blocked users: |
2ms |
others: | 236ms |
total: | 420ms |
0 / 0 |