我在做什麼錯了?我需要創建外鍵,但CONSTRAINT開頭的代碼在某種程度上是錯誤的,同樣我需要幫助我的觀點我認爲如果子查詢錯了,你能幫助我嗎?簡單的外鍵/創建查看問題
CREATE TABLE dealer(
dealershipId CHAR(10),
phone CHAR(10),
dealershipName CHAR(10),
webAddress char (10),
street CHAR (10),
city char (10),
zip char (5),
mCapacity INT,
managerFName CHAR (10),
managerLName CHAR (10),
PRIMARY KEY (dealershipId));
CREATE TABLE automobiles(
autoId CHAR (4),
vehiclecode VARCHAR (15),
manufacturer VARCHAR(15),
model VARCHAR (20),
style VARCHAR (5),
color VARCHAR (10),
ownership VARCHAR (8),
PRIMARY KEY (autoId)
CONSTRAINT fkHasRep FOREIGN KEY (dealershipId)
REFERENCE dealer(dealershipId) ON DELETE RESTRICT
);
--7.
CREATE VIEW division AS
SELECT dealershipName, webAddress, phone
FROM dealer
WHERE dealershipId IN
(SELECT manufacturer, model, style, ownership
FROM automobiles);
--8.
SELECT phone, manufacturer, model
FROM division;
謝謝零件已修復,我也在汽車表中缺少經銷商ID。現在你能幫助我看看嗎? – 2010-07-09 20:09:26
@Michael Quiles:查看更新 – 2010-07-09 20:14:28
,它不起作用,它只會從經銷商表中提取數據,而不會添加汽車表格。 – 2010-07-09 20:24:47