`

(ZZ)Oracle约束的关键字Enable/Disable/Validate/Novalidate

 
阅读更多

组合特性说明

 

Validate

Novalidate

已有记录

新增/删除记录

已有记录

新增/删除记录

Enable

Yes

Yes

No

Yes

Disable

Yes

No

No

No

Validate确保已有数据符合约束;

Novalidate不必考虑已有数据是否符合约束。

 

除非Novalidate被指定,Enable默认Validate

除非Validate被指定,Disable默认Novalidate

 

Enable ValidateEnable相同,检查已有记录和新增记录,确保都符合约束;

Enable Novalidate 允许已有记录不必满足约束条件,但新增/修改的记录必须满足;

Disable Validate禁用约束,删除约束上的索引,不允许修改任何被约束的记录;

Disable NovalidateDisable相同,禁用约束,删除约束上的索引,且允许修改被约束的记录。

建表

SQL> create table test(id int, name varchar2(10));

Table created

SQL> alter table test add constraint ck_id check(id > 10);

Table altered

测试1: Enable Validate

SQL> alter table test Enable validate constraint ck_id;

Table altered

SQL> insert into test values(5, 'Oracle');

insert into test values(5, 'Oracle')

ORA-02290: 违反检查约束条件 (MYHR.CK_ID)

SQL> insert into test values(17,'ERP');

1 row inserted

SQL> commit;

Commit complete

测试2: Enable Novalidate

SQL> alter table test disable constraint ck_id;

Table altered

SQL> insert into test values(5, 'Oracle');

1 row inserted

SQL> commit;

Commit complete

SQL> select * from test;

           ID NAME

----------- ----------

          17 ERP

            5 Oracle

 

SQL> alter table test enable novalidate constraint ck_id;

Table altered

SQL> insert into test values(32, 'SAP');

1 row inserted

SQL> insert into test values(3, 'Linux');

insert into test values(3, 'Linux')

ORA-02290: 违反检查约束条件 (MYHR.CK_ID)

SQL> commit;

Commit complete

测试3: Disable Validate

SQL> delete from test where id < 10;

1 row deleted

SQL> commit;

Commit complete

SQL> alter table test disable validate constraint ck_id;

Table altered

SQL> select * from test;

             ID NAME

------------- ----------

             17 ERP

             32 SAP

SQL> update test set name = 'Change' where id = 17;

update test set name = 'Change' where id = 17

ORA-25128: 不能对带有禁用和验证约束条件 (MYHR.CK_ID) 的表进行插入/更新/删除

测试4: Disable Novalidate

SQL> alter table test disable novalidate constraint ck_id;

Table altered

SQL> insert into test values(2, 'Linux');

1 row inserted

SQL> insert into test values(13, 'Windows');

1 row inserted

SQL> update test set name = 'Change' where id = 17;

1 row updated

SQL> commit;

Commit complete

SQL> select * from test;

          ID NAME

---------- ----------

          17 Change

          13 Windows

          32 SAP

           2 Linux

 

分享到:
评论

相关推荐

    .net WPF 实现图标按钮,点击图标enable/disable,并触发相应功能

    WPF实现图标按钮的enable 和disable功能,单击图标disable该功能,图标也跟着变化,再单击一次,图标和功能enable. .net framework 和.net core框架都能用,该Demo使用的是.net core的框架,修改引入的依赖项就可以...

    Oracle关键字(保留字)大全

    ### Oracle关键字(保留字)详解 #### 概述 在Oracle数据库系统中,关键字或保留字是用来执行特定功能和操作的预定义标识符。这些关键字对于编写有效的SQL语句至关重要,因为它们帮助开发者构建出清晰、逻辑严谨的...

    wndr 4700脱机下载固件

    - enable/disable SSH server (dropbear, enabled by default only for LAN). - enable/disable SWAP and set swap size - enable/disable transmission daemon (Bittorrent client). After each change you have ...

    ulps_enable_disable.zip

    标题 "ulps_enable_disable.zip" 暗示了这是一个与启用或禁用ULPS相关的软件配置包。ULPS,全称Ultra Low Power State(超低功耗状态),是计算机硬件,特别是显卡中的一种节能技术。它允许设备在不活动时进入一种极...

    Virtual Floppy driver

    SHELL Enable/disable the shell extension. OPEN Open a Virtual Floppy image. CLOSE Close a Virtual Floppy image. SAVE Save the current image into a file. PROTECT Enable/disable drive write protect...

    Furmark老版本

    6. added F2 key to enable / disable GPU monitoring (default: enabled);7. added F3 key to enable / disable the display of OpenGL errors (default: disabled);8. update: ZoomGPU 1.8.21 (GPU monitoring ...

    enable / disable proxy on IExplorer-开源

    这只是通常使用代理的便捷工具,但是在您不在站点时需要将其关闭。 这样,您不必每次都进入Internet选项。

    微星AMIBIOS设置参考.pdf

    微星AMIBIOS设置参考.pdf

    (免费)提供 adb -disable-verity 支持

    此adb工具包中包含了adb disable-verity命令,这里免费提供给大家使用,具体可看本人的文章 ”/system/bin/sh: disable-verity: not found 的解决方案“ 【使用方式】 platform-tools解压后即可使用。在cmd中通过cd...

    disable-devtool:通过f12按钮,右键单击和浏览器菜单禁用Web开发人员工具

    import disableDevtool from 'disable-devtool' ; disableDevtool ( ) ; 1.2脚本属性配置 &lt; script disable-devtool-auto src =' https://cdn.jsdelivr.net/npm/disable-devtool/disable-devtool.min.js ' &gt; ...

    ros2snap:(已停产)从ROS软件包中制作快照

    从ROS包构建Snappy应用 ros2snap是一个脚本,可以从ROS包中生成一个活泼的应用程序。 该脚本获取ROS包可能需要...# -c: Enable/disable copying of recursive dependencies # -s: Enable/disable building of snap # -h

    adb,支持adb disable-verity命令,解锁system分区

    `adb disable-verity` 是一个特定的adb命令,它涉及到Android系统的安全特性——verity模式。 verity模式是Android为了增强设备的安全性而引入的一种机制。它通过校验系统分区的哈希值来确保系统文件未被篡改,从而...

    adb_idea-1.6.3.zip

    可以通过快捷键快速对adb连接设备进行下列操作: ADB Uninstall App ADB Kill App ADB Start App ADB Restart App ...ADB Enable/Disable Wi-Fi ADB Enable/Disable Mobile Data 内附插件官方地址便于更新。

    Keil.STM32F1xx_DFP.2.1.0.pack

    Corrected Peripheral Reset and Clock enable/disable (check if peripheral is available on selected device) Corrected CTS handling and added signal CTS change event. SPI: Corrected Peripheral Reset ...

    jquery-fit:用于扩展元素高度的轻量级 jQuery 插件

    width: false, // enable/disable width fitting height: false, // enable/disable height fitting widthMargin: 0, // width to discount (useful if your element has padding/margin) heightMargin: 0, // ...

    cmake-tools.vsix

    Add setting to enable/disable automatic reconfiguring of projects. #1259 Partial/full CMT activation improperly persisted for multi-root projects. #1269 Fix MacOS debugging to work out of the box. #...

    跨Unix平台视频比对工具,基于OpenCV(源码)

    opencv 介绍/Introduction 跨Unix平台视频比对工具,基于OpenCV Crossplatform video comparision tool, based on OpenCV 安装教程/Installation 安装opencv / Install opencv brew ...x enable/disable automat

    Animation-Style_Dialog_Class.zip_Void_ The_c vfc class dialog

    制作动画的类,很不错的 // construction CAniDialog(UINT nDlgID, CWnd* pParent...// temporarily enable/disable animation void EnableAni(BOOL bEnable = TRUE) // check object status BOOL IsAniValid() const

    Android代码-清理你的状态栏显示信息App

    Clean Status Bar ...Use the ToggleReceiver to enable/disable Clean Status Bar programmatically, e.g. to automate taking screenshots. final Bundle extras = new Bundle(); extras.putBoolean("enabled

    Android代码-基于ASM,通过注解,实现对方法调用时的参数、返回值、耗时等信息的纪录。

    Daffodil Daffodil is an Annotation-triggered method call logging library. Usage Add daffodil closure in build.gradle daffodil { ...Enable/Disable daffodil in runtime DaffodilPrinter.set

Global site tag (gtag.js) - Google Analytics