دنبال کننده ها

۱۳۹۷ فروردین ۹, پنجشنبه

sql - Why is my create table failing? - does not match primary key

[ad_1]



This is what I am trying to create:



CREATE TABLE VEHICLEREPORT (
DeptID char(2) not null,
Vin# char(3) not null,
Miles varchar(6) not null,
Bill# char(3) not null,
EID char(3) not null,

Primary Key (DeptID, Vin#),
Foreign Key(bill#) REFERENCES billing,
Foreign Key (EID) REFERENCES Employee);


The issue is with my reference to billing. The error says:



The number of columns in the referencing column list for foreign key 'FK__VEHICLERE__Bill#__5AEE82B9' does not match those of the primary key in the referenced table 'Billing'.


but my billing table entered fine:



CREATE TABLE BILLING 
(
VIN# char(3),
BILL# char(3),

Primary Key (VIN#, Bill#),
Foreign Key (VIN#) REFERENCES vehicle);


What am i missing with this?



Appreciate the help.




[ad_2]

لینک منبع