Created
March 30, 2017 00:47
-
-
Save SeanNotman97/10e6ff6aec9656535698cd0b71c4aaea to your computer and use it in GitHub Desktop.
Help
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE "CUSTOMER_SN" | |
( "CUSTOMERID" NUMBER(3,0) NOT NULL ENABLE, | |
"USERNAME" VARCHAR2(15) NOT NULL ENABLE, | |
"EMAIL" VARCHAR2(50), | |
"CUSTOMERTYPE" VARCHAR2(6) DEFAULT 'Bronze' NOT NULL ENABLE, | |
CONSTRAINT "CUSTOMER_SN_PK" PRIMARY KEY ("CUSTOMERID") | |
USING INDEX ENABLE, | |
CONSTRAINT "CUSTOMER_SN_UK1" UNIQUE ("USERNAME", "EMAIL") | |
USING INDEX ENABLE, | |
CONSTRAINT "CHECK_TYPE" CHECK (CustomerType IN ('Bronze', 'Silver', 'Gold')) ENABLE | |
) | |
/ | |
CREATE OR REPLACE EDITIONABLE TRIGGER "BI_CUSTOMER_SN" | |
before insert on "CUSTOMER_SN" | |
for each row | |
begin | |
if :NEW."CUSTOMERID" is null then | |
select "CUSTOMER_SN_SEQ1".nextval into :NEW."CUSTOMERID" from sys.dual; | |
end if; | |
if :NEW."CUSTOMERTYPE" is null then | |
:NEW."CUSTOMERTYPE" := 'BRONZE'; | |
end if; | |
end; | |
/ | |
ALTER TRIGGER "BI_CUSTOMER_SN" ENABLE | |
/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment