Examine the following statement that is used to modify the primary key constraint on the SALES
table:
SQL> ALTER TABLE SALES MODIFY CONSTRAINT pk DISABLE VALIDATE;
Which three statements are true regarding the above command? (Choose three.)
A.The constraint remains valid.
B.The index on the constraint is dropped.
C.It allows the loading of data into the table using SQL *Loader.
D.New data conforms to the constraint, but existing data is not checked.
E.It allows the data manipulation on the table using INSERT/UPDATE/DELETE SQL statements.
正确答案: ABC
DISABLE VALIDATE disables the constraint and drops the index on the constraint, but keeps the constraint valid. This feature is most useful in data warehousing situations, because it lets you load large amounts of data while also saving space by not having an index. This setting lets you load data from a nonpartitioned table into a partitioned table using the exchange_partition_subpart clause of the ALTER TABLE statement or using SQL*Loader. All other modifications to the table (inserts, updates, and deletes) by other SQL statements are disallowed
大意是说DISABLE VALIDATE会disable键并删除在 constraint上的索引,同时, constraint还是valid。这个特性在数据仓库的环境中特别有用。因为当加载大量数据时,没有索引,可以节省很大的空间(也省去了维护索引的资源)。
这个设定允许使用从非分区表中通过分区交换向分区表中加载数据。其他所有DML云集对表的修改都不允许。
SQL> create table test2 as select * from test1;
Table created.
SQL> alter table test2 add constraint pk_test2 primary key (pid);
Table altered.
SQL> alter table test2 modify constraint pk_test2 disable validate;
Table altered.
SQL> update test2 set pid = 20;
update test2 set pid = 20
*
ERROR at line 1:
ORA-25128: No insert/update/delete on table with constraint (SCOTT.PK_TEST2)
disabled and validated
SQL> select index_name from user_indexes where table_name='TEST2';
no rows selected
可以看到,在disable validate的情况下,不允许对存在约束的列进行修改操作。同时,约束(这个例子为主键)的索引也不复存在(被删除了)。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/8520577/viewspace-2040194/
,如需转载,请注明出处,否则将追究法律责任。