1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| CREATE TABLE ORDERS ( ORDER_ID NUMBER(12, 0) , ORDER_DATE DATE , ORDER_MODE VARCHAR2(8 BYTE) , CUSTOMER_ID NUMBER(6, 0) , ORDER_STATUS NUMBER(2, 0) , ORDER_TOTAL NUMBER(8, 2) DEFAULT 0 , SALES_REP_ID NUMBER(6, 0) , PROMOTION_ID NUMBER(6, 0) , CONSTRAINT PK_ORDER PRIMARY KEY (ORDER_ID) , CONSTRAINT CK_ORDER_MODE CHECK (ORDER_MODE in ('direct', 'online')) );
CREATE TABLE ORDER_ITEMS ( ORDER_ID NUMBER(12,0), LINE_ITEM_ID NUMBER(3,0) , ORDER_MODE VARCHAR2(8 BYTE), PRODUCT_ID NUMBER(3,0), UNIT_PRICE NUMBER(8,2) DEFAULT 0, QUANTITY NUMBER(8,0) DEFAULT 0, CONSTRAINT PK_ORDER_ITEMS PRIMARY KEY (ORDER_ID, LINE_ITEM_ID) );
CREATE TABLE PROMOTIONS ( PROMO_ID NUMBER(12,0), PROMO_NAME VARCHAR2(8 BYTE), CONSTRAINT PK_PROMOTIONS PRIMARY KEY (PROMO_ID) );
CREATE TABLE ex2_9 ( num1 NUMBER CONSTRAINTS check1 CHECK ( num1 BETWEEN 1 AND 9), gender VARCHAR2(10) CONSTRAINTS check2 CHECK ( gender IN ('MALE', 'FEMALE')) );
SELECT constraint_name, constraint_type, table_name, search_condition FROM user_constraints WHERE table_name = 'EX2_9'; INSERT INTO ex2_9 VALUES (10, 'MAN'); INSERT INTO ex2_9 VALUES (5, 'FEMALE');
|