我試圖記錄添加到下面兩個表,不能添加或更新子行
CREATE TABLE customer
(Custno CHAR(3),
Custname VARCHAR(25) NOT NULL,
Custstreet VARCHAR(30) NOT NULL,
Custcity VARCHAR(15) NOT NULL,
Custprov VARCHAR(3) NOT NULL,
Custpcode VARCHAR(6) NOT NULL,
Disc DECIMAL(3,1),
Balance DECIMAL(7,2),
Credlimit DECIMAL(5),
Srepno CHAR(3),
CONSTRAINT pkcustno PRIMARY KEY (Custno),
CONSTRAINT fksrepno FOREIGN KEY (Srepno) REFERENCES salesrep(Srepno)
);
CREATE TABLE orders
(Orderno CHAR(5) UNIQUE NOT NULL,
Orderdate DATE,
Custno CHAR(3) NOT NULL,
CONSTRAINT fkordercust FOREIGN KEY (Custno) REFERENCES customer (Custno)
);
當加入這樣的,
INSERT INTO orders(Orderno, Orderdate, Custno) VALUES('14587','2011-11-09', '125');
INSERT INTO orders(Orderno, Orderdate, Custno) VALUES('11547','2011-11-07', '125');
我得到的,「不能添加或更新子行:外鍵約束失敗(sh
。orders
,CONSTRAINT fkordercust
FOREIGN KEY(Custno
)REFERENCES customer
(Custno
)) 「 桌子有問題嗎?