下面为您介绍的DB2建表语句中含有约束,该DB2建表语句供您参考,希望对您学习DB2建表语句方面能够有所帮助。
class="dp-xml">
- 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
- )