今天在10.2.0.1上测试了一下enablenovalidate功能,以下是整个过程:
SQL> conn scott@oradb
输入口令: *****
已连接。
INSTANCE_NAMEHOST_NAME
VERSION STARTUP_TIMESTATUS DATABASE_STATUS
---------------- -------------------- ----------------- ------------------- ------------ -----------------
oradb
orasvr
10.2.0.1.02006-07-18 13:58:41 OPEN ACTIVE
SQL> drop table test1 cascade constraints purge;
表已删除。
SQL> create table test1
2(id int,
3name varchar2(40),
4constraint pk_test1 primary key (id) disable);
表已创建。
SQL> select constraint_name,constraint_type,status from user_constraints
2where table_name = 'TEST1';
CONSTRAINT_NAME
C STATUS
------------------------------ - --------
PK_TEST1
P DISABLED
SQL> insert into test1
2values(1,'sdfsdf');
已创建 1 行。
SQL> /
已创建 1 行。
SQL> /
已创建 1 行。
SQL> /
已创建 1 行。
SQL> commit;
提交完成。
SQL> select * from test1;
ID NAME
---------- ----------------------------------------
1 sdfsdf
1 sdfsdf
1 sdfsdf
1 sdfsdf
SQL> alter table test1 modify constraint pk_test1 enable novalidate;
alter table test1 modify constraint pk_test1 enable novalidate
*
第 1 行出现错误:
ORA-02437: cannot validate (SCOTT.PK_TEST1) - primary key violated
SQL>
SQL> delete from test1 a
2where rowidselect * from test1;
ID NAME
---------- ----------------------------------------
1 sdfsdf
SQL> alter table test1 modify constraint pk_test1 enable novalidate;
表已更改。
SQL> select constraint_name,constraint_type,status from user_constraints
2where table_name = 'TEST1';
CONSTRAINT_NAME
C STATUS
------------------------------ - --------
PK_TEST1
P ENABLED
SQL> select * from v$version;
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
PL/SQL Release 10.2.0.1.0 - Production
CORE10.2.0.1.0Production
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
我的问题是,enable novalidate是存在的数据不进行校验,只是对新加入的进行校验,难道是我的操作有问题,请高手指点
|