alter table using index
#下列指定using index的行為,用於新增主鍵約束時,如果索引存在,就把索引與主鍵關聯;
也可以指定建立索引的語句,或者不指定具體的索引,如果不存在,會預設建立與主鍵約束同名的索引
Using Indexes to Enforce Constraints
When defining the state of a unique or primary key constraint, you can specify an index for Oracle to use to enforce the constraint, or you can instruct Oracle to create the index used to enforce the constraint.
也可以指定建立索引的語句,或者不指定具體的索引,如果不存在,會預設建立與主鍵約束同名的索引
Using Indexes to Enforce Constraints
When defining the state of a unique or primary key constraint, you can specify an index for Oracle to use to enforce the constraint, or you can instruct Oracle to create the index used to enforce the constraint.
using_index_clause
You can specify the using_index_clause only when enabling unique or primary key constraints. You can specify the clauses of the using_index_clause in any order, but you can specify each clause only once.
You can specify the using_index_clause only when enabling unique or primary key constraints. You can specify the clauses of the using_index_clause in any order, but you can specify each clause only once.
•If you specify schema.index, then Oracle attempts to enforce the constraint using the specified index. If Oracle cannot find the index or cannot use the index to enforce the constraint, then Oracle returns an error.
•If you specify the create_index_statement, then Oracle attempts to create the index and use it to enforce the constraint. If Oracle cannot create the index or cannot use the index to enforce the constraint, then Oracle returns an error.
•If you neither specify an existing index nor create a new index, then Oracle creates the index. In this case:
◦The index receives the same name as the constraint.
◦If table is partitioned, then you can specify a locally or globally partitioned index for the unique or primary key constraint.
SQL> desc t_using;
Name Null? Type
----------------------------------------- -------- ----------------------------
A NUMBER(38)
Name Null? Type
----------------------------------------- -------- ----------------------------
A NUMBER(38)
SQL> alter table t_using add b int;
Table altered.
SQL> alter table t_using add constraint
2 con_uni_x unique(b) using index tablespace zxy;#利用using index並指定索引儲存在表空間zxy中
Table altered.
SQL> select index_name from user_indexes where table_name='T_USING';
INDEX_NAME
------------------------------
CON_UNI_X
CON_UNI
------------------------------
CON_UNI_X
CON_UNI
SQL> drop index con_uni_x;
drop index con_uni_x
*
ERROR at line 1:
ORA-02429: cannot drop index used for enforcement of unique/primary key
drop index con_uni_x
*
ERROR at line 1:
ORA-02429: cannot drop index used for enforcement of unique/primary key
SQL>
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9240380/viewspace-666318/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Using index condition Using indexIndex
- Alter table for ORACLEOracle
- alter table move 和 alter table shrink space的區別
- alter index rebuild與index_statsIndexRebuild
- using indexIndex
- mysql的ALTER TABLE命令MySql
- oracle alter table詳解Oracle
- best practice of rebuild your partition table local index online by using: "update indexes"RebuildIndex
- alter index ind1 rebuild 和alter index ind1 rebuild onlineIndexRebuild
- index table (IOT)Index
- Oracle alter index rebuild 說明OracleIndexRebuild
- MySQL explain結果Extra中"Using Index"與"Using where; Using index"區別MySqlAIIndex
- create a partition table using a exsit table
- v$lock之alter table drop column與alter table set unused column區別系列五
- alter index compute statistics與analyze index的比較Index
- partition table and partition indexIndex
- alter table語法增補(一)
- ALTER TABLE MOVE | SHRINK SPACE區別
- MYSQL中的type:index 和 Extra:Using indexMySqlIndex
- TABLE size (including table,index,lob,lobindex)Index
- alter index rebuild 與 rebuild onlineIndexRebuild
- ALTER TABLE MOVE和SHRINK SPACE區別
- 收集full table / index scan sqlIndexSQL
- alter table move 與shrink space的區別
- alter table move跟shrink space的區別
- alter table engine=memory ERROR 1114Error
- 【INDEX】使用“alter index ××× monitoring usage;”語句監控索引使用與否Index索引
- 查詢使用表空間的TABLE,INDEX,INDEX SUBPARTITIONIndex
- CREATE INDEX index1 ON table1(col1)Index
- alter index rebuild online引發的血案IndexRebuild
- alter index ... rebuild online的機制(zt)IndexRebuild
- alter index unusable無法起作用的情況Index
- 資料庫表--index organized table資料庫IndexZed
- 資料庫表--index clustered table資料庫Index
- Get table and index DDL in the easy way(轉)Index
- Oracle Index-organized table (IOT)概述OracleIndexZed
- 索引組織表(Index Organizied Table)索引Index
- alter table nologging /*+APPEND PARALLEL(n)*/APPParallel