SQL> create table k ( name varchar2(20),type varchar2(10) default 'type1' check(type in ( 'type1','type2','type3')));Table createdSQL> desc k; Name Type Nullable Default Comments ---- ------------ -------- ------- -------- NAME VARCHAR2(20) Y TYPE VARCHAR2(10) Y 'type1' SQL> SQL> select table_name,constraint_name,constraint_type,search_condition from user_constraints where table_name ='K';TABLE_NAME CONSTRAINT_NAME CONSTRAINT_TYPE SEARCH_CONDITION ------------------------------ ------------------------------ --------------- -------------------------------------------------------------------------------- K SYS_C00187257 C type in ( 'type1','type2','type3')SQL> SQL> insert into k (name) values ( 'asldfj');1 row insertedSQL> insert into k values ( '2','type3');1 row insertedSQL> insert into k values ( '2','type4');insert into k values ( '2','type4')ORA-02290: 违反检查约束条件 (APPS.SYS_C00187257)SQL> insert into k values ( '5345','abc');insert into k values ( '5345','abc')ORA-02290: 违反检查约束条件 (APPS.SYS_C00187257)SQL> commit;Commit completeSQL> select * from k;NAME TYPE -------------------- ---------- asldfj type1 2 type3SQL>
Name Type Nullable Default Comments
---- ------------ -------- ------- --------
NAME VARCHAR2(20) Y
TYPE VARCHAR2(10) Y 'type1' SQL>
SQL> select table_name,constraint_name,constraint_type,search_condition from user_constraints where table_name ='K';TABLE_NAME CONSTRAINT_NAME CONSTRAINT_TYPE SEARCH_CONDITION
------------------------------ ------------------------------ --------------- --------------------------------------------------------------------------------
K SYS_C00187257 C type in ( 'type1','type2','type3')SQL>
SQL> insert into k (name) values ( 'asldfj');1 row insertedSQL> insert into k values ( '2','type3');1 row insertedSQL> insert into k values ( '2','type4');insert into k values ( '2','type4')ORA-02290: 违反检查约束条件 (APPS.SYS_C00187257)SQL> insert into k values ( '5345','abc');insert into k values ( '5345','abc')ORA-02290: 违反检查约束条件 (APPS.SYS_C00187257)SQL> commit;Commit completeSQL> select * from k;NAME TYPE
-------------------- ----------
asldfj type1
2 type3SQL>