0
当连接飞行表书籍表和公司时,我得到错误1215.我连接其他表没有问题。谁能告诉我什么是错的?知道谁可以检查我的mysql工作台错误代码1215?
create database aviacion;
use aviacion;
create Table Compañia(
Codigo char(8) NOT NULL,
Nombre varchar(15),
Volumen_venta decimal(10,0)
);
create Table Pais(
Codigo char(8) NOT NULL,
Nombre varchar(10),
Idioma varchar(10),
Moneda varchar(10)
);
create Table Avion(
Nombre varchar(10) NOT NULL,
Consumo_gas int(8),
Cantidad_asientos int(25)
);
create Table Viaje(
Codigo char(8) NOT NULL,
Lugar varchar(10),
Destino varchar(10),
Cantidad_km int(8)
);
create Table Vuelo(
Precio decimal(10,0) NOT NULL,
Tiempo_duracion datetime NOT NULL
);
Alter Table Compañia Add Primary Key (Codigo);
Alter Table Pais Add Primary Key (Codigo);
Alter Table Avion Add Primary Key (Nombre);
Alter Table Viaje Add Primary Key (Codigo);
Alter Table Vuelo Add Primary Key (Precio);
Alter Table Pais Add Foreign Key (Codigo) References Compañia(Codigo);
Alter Table Avion Add Foreign Key (Nombre) References Pais(Codigo);
Alter Table Viaje Add Foreign Key (Codigo) References Avion(Nombre);
Alter Table Vuelo Add Foreign Key (Precio) References Viaje(Codigo);
Alter Table Vuelo Add Foreign Key (Precio) References Compañia(Codigo);
顺便说一句你永远不应该在一个表中混合使用CHAR和VARCHAR – msrd0 2014-08-29 19:35:08
有没有这个建议的证据? – 2014-09-01 09:52:57