0
CREATE TABLE Customer
(
CustomerID NUMBER NOT NULL,
AccountID NUMBER(10) NOT NULL,
CustomerType VARCHAR(10) NOT NULL,
CustomerStatus VARCHAR(10) NOT NULL,
CONSTRAINT customer_pk PRIMARY KEY (CustomerID),
CONSTRAINT check_customer_status CHECK(CustomerStatus IN ('Ineligible', 'Eligible')),
CONSTRAINT check_customer_type CHECK(CustomerType IN ('NonResident', 'Residential'))
);
Alter table CUSTOMER add CONSTRAINT res_customer_type UNIQUE (CustomerID, CustomerType)
CREATE TABLE nonresidential
(
CustomerID NUMBER NOT NULL,
CustomerType VARCHAR(10) NOT NULL,
BusinessName VARCHAR(10) NOT NULL,
ABNNumber NUMBER(10),
Email VARCHAR(35),
CONSTRAINT pk_nrtable PRIMARY KEY (CustomerID),
CONSTRAINT nonres_type CHECK (CustomerType = 'nonresident'),
CONSTRAINT res_customer_type UNIQUE (CustomerID, CustomerType) REFERENCES Customer(CustomerID, CustomerType)
);
最後一行繼續作爲缺少的括號(圍繞唯一約束的引用行)出現。我想指定唯一約束來在客戶下創建子類型表。Oracle SQL分類子類型
P.S我使用Oracle SQL,感謝
我沒有執行這些全部一次,他們seperately執行。 – pooch 2014-10-17 09:53:05
修改表已成功添加,但由於所稱的丟失括號而導致「非居民」表創建不成功 – pooch 2014-10-17 09:53:55
它的工作原理非常感謝 – pooch 2014-10-17 10:07:00