Teradata中的外键值无效



我得到了一个无效的外键值,我不知道它是什么,这是错误。

作为多个语句执行。

语句1:

DATABASE已完成。已处理0行。运行时间=00:00:00-047

声明2:

Insert语句失败。失败[2700:23000]引用约束冲突:无效的外键值。

当我尝试插入时会发生这种情况:

insert into SALE values (1,30.45,'2020-12-31','VMBNH',1,1);
into the SALE Table

这是桌子,我还包括我已经放在桌子上的插页。

CREATE TABLE EQUIPMENT_DETAIL 
(   
EquipDetailID INT NOT NULL,   
Make VARCHAR(20) NOT NULL,   
Equipment_Type VARCHAR(20) NOT NULL,   
Model VARCHAR(20) NOT NULL,   
PRIMARY KEY (EquipDetailID) 
);
CREATE TABLE CUSTOMER 
(
CustID INT NOT NULL,   
CustName VARCHAR(40) NOT NULL,   
CustCategory VARCHAR(20) NOT NULL,   
PRIMARY KEY (CustID)
);    
CREATE TABLE EQUIPMENT 
(   
SerialNo VARCHAR(20) NOT NULL,  
LastInspectedDate DATE NOT NULL,   
DateMade DATE NOT NULL,  
EquipDetailID INT NOT NULL,   
PRIMARY KEY (SerialNo),   
FOREIGN KEY (EquipDetailID) REFERENCES EQUIPMENT_DETAIL(EquipDetailID) 
);
CREATE TABLE SALE 
(   
SaleTransID INT NOT NULL,   
Price DECIMAL(4,2) NOT NULL,   
Sale_Date DATE NOT NULL,   
SerialNo VARCHAR(20) NOT NULL, 
CustID INT NOT NULL,   
SRepID INT NOT NULL,   
PRIMARY KEY(SaleTransID),   
FOREIGN KEY (SerialNo) REFERENCES EQUIPMENT(SerialNo),   
FOREIGN KEY (CustID) REFERENCES CUSTOMER(CustID),   
FOREIGN KEY (SRepID) REFERENCES SALES_REP(SRepID)
);
CREATE TABLE RENTAL 
(   
Price DECIMAL(4,2) NOT NULL,   
Rental_Date DATE NOT NULL,   
RentTransID INT NOT NULL,   
SerialNo VARCHAR(20) NOT NULL,   
CustID INT NOT NULL,   
SRepID INT NOT NULL,   
PRIMARY KEY (RentTransID),   
FOREIGN KEY (SerialNo) REFERENCES EQUIPMENT(SerialNo),   
FOREIGN KEY (CustID) REFERENCES CUSTOMER(CustID),   
FOREIGN KEY (SRepID) REFERENCES SALES_REP(SRepID)
);
CREATE TABLE SALES_REP 
(   
SRepID INT NOT NULL,   
SRepLName VARCHAR(40) NOT NULL,   
SRepFName VARCHAR(20) NOT NULL,   
Rank_ID VARCHAR(20) NOT NULL,   
Mentors_SRepID INT,   
PRIMARY KEY (SRepID),  
FOREIGN KEY (Mentors_SRepID) REFERENCES SALES_REP(SRepID) 
);

insert into EQUIPMENT_DETAIL values (1,'CFT','Drill','B123');
insert into EQUIPMENT_DETAIL values (2,'CFT','Hammer','B124');
insert into EQUIPMENT_DETAIL values (3,'MKT','Saw','M123');
insert into EQUIPMENT_DETAIL values (4'MKT','Wrench','M124');
insert into EQUIPMENT_DETAIL values (5'SNP','Flat Head','S123');
insert into CUSTOMER values (1,'Jim Halpert','A');
insert into CUSTOMER values (2,'Michael Scott','B');

insert into EQUIPMENT values ('KDJHS','2021-01-12','2010-11-11',1);
insert into EQUIPMENT values ('VMBNH','2021-03-05','2007-12-12',2);
insert into EQUIPMENT values ('QIEIR','2021-03-05','2007-12-12',3);
insert into EQUIPMENT values ('PTPYO','2021-03-05','2007-12-12',4);
insert into EQUIPMENT values ('AGSGD','2021-03-05','2007-12-12',5);

我不得不从SALE(SRepID(中删除外键约束

相关内容

  • 没有找到相关文章

最新更新