Oracle ->> ENABLE VALIDATE & DISABLE VALIDATE

这里找到一篇博文对这两个用法的解释:http://www.cnblogs.com/rootq/archive/2008/09/23/1297400.html

启用约束:

enable( validate) :启用约束,创建索引,对已有及新加入的数据执行约束. e

enable novalidate :启用约束,创建索引,仅对新加入的数据强制执行约束,而不管表中的现有数据.

禁用约束:

disable( novalidate):关闭约束,删除索引,可以对约束列的数据进行修改等操作.

disable validate :关闭约束,删除索引,不能对表进行 插入/更新/删除等操作.

这里自己做了下实验,也确实验证上面的说法。

下面是DISABLE VALIDATE的实验结果

declare
      num   number;
begin
      select count(1) into num from all_tables where TABLE_NAME = ‘TEST2‘;
      if   num=1   then
          execute immediate ‘drop table TEST2‘;
      end   if;
end;
/

create table Test2(
col1 int CONSTRAINT cons_test2_1 NOT NULL CHECK(col1>10) DISABLE VALIDATE,
col2 varchar(100) null
);
/

insert into Test2(col1,col2) values(1,‘a‘);

在行 32 上开始执行命令时出错:insert into Test2(col1,col2) values(1,‘a‘)命令出错, 行: 32 列: 1错误报告:SQL 错误: ORA-25128: 不能对带有禁用和验证约束条件 (SYSTEM.SYS_C009875) 的表进行插入/更新/删除25128. 00000 -  "No insert/update/delete on table with constraint (%s.%s) disabled and validated"*Cause:    Try to insert/update/delete on table with DISABLE VALIDATE constraint.*Action:   Change the constraint‘s states.

下面是ENANLE VALIDATE的实验结果

declare
      num   number;
begin
      select count(1) into num from all_tables where TABLE_NAME = ‘TEST2‘;
      if   num=1   then
          execute immediate ‘drop table TEST2‘;
      end   if;
end;
/

create table Test2(
col1 int CONSTRAINT cons_test2_1 NOT NULL CHECK(col1>10) ENABLE VALIDATE,
col2 varchar(100) null
);
/

insert into Test2(col1,col2) values(1,‘a‘);

在行 32 上开始执行命令时出错:insert into Test2(col1,col2) values(1,‘a‘)错误报告:SQL 错误: ORA-02290: 违反检查约束条件 (SYSTEM.SYS_C009877)02290. 00000 -  "check constraint (%s.%s) violated"*Cause:    The values being inserted do not satisfy the named check           *Action:   do not insert values that violate the constraint.

下面是ENABLE NOVALIDATE的实验结果。

declare
      num   number;
begin
      select count(1) into num from all_tables where TABLE_NAME = ‘TEST2‘;
      if   num=1   then
          execute immediate ‘drop table TEST2‘;
      end   if;
end;
/

create table Test2(
col1 int,
col2 varchar(100) null
);
/

insert into Test2(col1,col2) values(1,‘a‘);
/

alter table Test2 add CONSTRAINT cons_test2_1 CHECK(col1>10) ENABLE NOVALIDATE;
/

select * from Test2;
/

insert into Test2(col1,col2) values(2,‘b‘);

table TEST2 已创建。 1 行已插入。 table TEST2已变更。 >>Query Run In:查询结果 1

在行 41 上开始执行命令时出错: insert into Test2(col1,col2) values(2,‘b‘) 错误报告: SQL 错误: ORA-02290: 违反检查约束条件 (SYSTEM.CONS_TEST2_1) 02290. 00000 -  "check constraint (%s.%s) violated" *Cause:    The values being inserted do not satisfy the named check            *Action:   do not insert values that violate the constraint.

时间: 2024-10-11 13:21:20

Oracle ->> ENABLE VALIDATE & DISABLE VALIDATE的相关文章

ext4 form loadrecord disable validate

ext版本:4.2 需求: 在数据record绑定到form的时候,Ext会触发field的change事件和validate事件.以至于,新建的空表单界面,会出现验证不通过的样式,如下图: 解决思路: 在form loadRecord之前,禁止field的change()事件,loadRecord之后,开启field的change()事件.loadRecord方法会调用basicForm的setValues()方法,所以,重写setValues()方法,如下: Ext.override(Ext

The project references RTL attributes, but does not explicitly enable or disable RTL support 解决办法

If you do not support RTL (= Right To Left locales), you need to replace all references of start by left and end byright in your xml layouts. The attributes "start", "end", "paddingStart", "paddingEnd", "androi

Oracle alter index disable/unusable的区别

alter index index_name disable,enable针对函数索引. SQL> create table test as select * from all_objects; SQL> create index ind_t_object_id on test(object_id) nologging; SQL> exec dbms_stats.gather_table_stats(user,'test',cascade => true); SQL> set

iOS buttonset Enable or Disable

在 .h 文件里: @property (retain, nonatomic) IBOutlet UIButton *btnMyButton; 在函数方法中: btnMyButton.enabled = NO; // disable my button btnMyButton.enabled = YES; // enable my button 转载自: http://stackoverflow.com/questions/9012100/enable-disable-a-button-in-x

IE, Chrome and Firefox script to enable or disable proxy settings

For IE and Chrome set the proxy server up on IE and close IE. Create and new texts file and copy the following into it: Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings]"ProxyEnable&q

Enable and Disable RDP NLA using PowerShell

Enable_RDP_NLA #Powershell script to enable Network Level Authentication for Remote Desktop Services Connections #The need arose when trying to RDP using a third party application and it gave the following error: #The remote computer '<machine name>

oracle约束条件状态

Oracle完整性约束有一下4种: • DISABLE NOVALIDATE • ENABLE NOVALIDATE • DISABLE VALIDATE • ENABLE VALIDATE • DISABLE NOVALIDATE 对原有和新数据都不校验. 适用只读表,提升性能. 当数据来自验证过的源,而且表是只读表时,通常会使用此状态.因此,不会将新数据输入表中.在已清理了数据的数据仓库环境中使用NOVALIDATE.此时不需要进行验证,因而可以节省很多时间. • ENABLE NOVALI

OCP-1Z0-052-V8 02-10题

10. Examine the following statement that is used to modify the 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

jquery.validate结合poshytip实现表单完美验证

1.需要引用的js <script src="/Themes/default/lib/jquery/jquery-1.7.1.min.js" type="text/javascript"></script> <!--气泡提示--> <script src="/Themes/default/lib/poshytip/jquery.poshytip.min.js" type="text/javasc