下面為您介紹的DB2建表語句中含有約束,該DB2建表語句供您參考,希望對您學習DB2建表語句方面能夠有所幫助。
- CREATE TABLE EMPLOYEE
- ( EMPNO INTGRATE NOT NULL PRIMARY KEY,
- JOB VARCHAR(10) CONSTRAINT CHECH_JOB
- CHECK(JOB IN ('Engineer','Sales','Manager')),
- ...,
- CONSTRAINT CHECK_AGE_SALRY CHECK(NOT(AGE<30 AND SALARY>6000))
- )
- 2.CREATE TABLE EMPDATA
- (EMPNO INTGRATE NOT NULL,
- SEX CHAR(1) NOT NULL CONSTRAINT SEXOK CHECK(SEX IN('M','F'))
- NOT ENFORCED //DB2不要在插入或更新時強制執行這個列的檢查
- ENABLE QUERY OPTIMIZATION, //DB2在對該表運行SELECT語句時使用它
- SALARY INTGRATE NOT NULL,
- CONSTRAINT SALARYOK CHECK (SALARY BETWEEN 0 AND 100000)
- NOT ENFORCED
- ENABLE QUERY OPTIMIZATION
- )