oracle10.2.0.4_create table_constraint_index

wisdomone1發表於2010-06-25
SQL> create table t_using(a int constraint con_not_null not null,b char(10)
  2  constraint con_uni unique,c int constraint con_check check(c>10));
Table created.
SQL> select index_name,index_type,table_name,uniqueness,compression,status from user_indexes where table_name='T_USING';
INDEX_NAME                     INDEX_TYPE
------------------------------ ---------------------------
TABLE_NAME                     UNIQUENES COMPRESS STATUS
------------------------------ --------- -------- --------
CON_UNI                        NORMAL
T_USING                        UNIQUE    DISABLED VALID

SQL> select constraint_name,constraint_type,table_name,status,index_name from user_constraints where constraint_name='PK_T_USING';
no rows selected
SQL> select constraint_name,constraint_type,table_name,status,index_name from user_constraints where table_name='T_USING';
CONSTRAINT_NAME                C TABLE_NAME                     STATUS
------------------------------ - ------------------------------ --------
INDEX_NAME
------------------------------
CON_NOT_NULL                   C T_USING                        ENABLED

CON_CHECK                      C T_USING                        ENABLED

CON_UNI                        U T_USING                        ENABLED
CON_UNI

SQL> drop index con_uni;#刪除不了此索引,因為此索引是由唯一約束生成的,可以直接刪除對應的約束
drop index con_uni
           *
ERROR at line 1:
ORA-02429: cannot drop index used for enforcement of unique/primary key

SQL> drop constraint con_uni;

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9240380/viewspace-666286/,如需轉載,請註明出處,否則將追究法律責任。