当前位置: 首页 > news >正文

PK Nounique CASCADE DROP INDEX keep index

Explicit Control Over Indexes when Creating, Disabling, or Dropping PK/Unique Constraints (Doc ID 139666.1)​编辑To Bottom


PURPOSEIn Oracle 9i, the DBA has an explicit control over how indexes are affectedwhile creating, disabling, or dropping Primary Key (PK) and unique constraints.This bulletin explains the different behaviours of indexes associated withPrimary Key or UNIQUE constraints according to the new clauses used when you execute one of the following commands:CREATE TABLE ... PRIMARY KEY/UNIQUEALTER TABLE  ... DISABLE PRIMARY KEY/UNIQUEALTER TABLE  ... DROP PRIMARY KEY/UNIQUESCOPE & APPLICATIONIt is important for DBAs to know what happens to the indexes when creating,disabling or dropping a constraint relying on an index, since indexes may have to be rebuilt after these operations. This can have two consequences:- Indexes may be missing for the Cost Based Optimizer (CBO) if the DBA thinks that the index was not dropped. This can have a major impact on performance.- Index rebuilding takes time.Explicit control over INDEXES when DISABLING/DROPPING PK, Unique constraints:
=============================================================================A. Creation of Primary Key/Unique constraints and associated index ----------------------------------------------------------------In the following views, depending on the way you created the Primary Key (PK)or UNIQUE constraint and its associated index, you get these different combinations:+-----------------+        +------------+| DBA_CONSTRAINTS |        | DBA_INDEXES|+-----------------+        +------------+-----------------------------   ------------Constraint_name   Index_name     Index_name--------------- -------------   ------------
Case 1: Create constraint, and index   PK_EMP_ID     EMP_ID_IX      EMP_ID_IX    explicitely within the samestatement.Case 2: Create constraint, and index   PK_EMP_ID     PK_EMP_ID      PK_EMP_ID    implicitely within the same statement.Case 3: Create constraint and index    PK_EMP_ID         -          EMP_ID_IX   separately within twostatements.Enable the constraint.         PK_EMP_ID     EMP_ID_IX      EMP_ID_IX-------------------------------------------------------------------------
Case 1: Create constraint and index explicitely within the same statement
-------------------------------------------------------------------------SQL> drop table <OWNER>.<TABLE_NAME>
Table dropped.SQL> create table <OWNER>.<TABLE_NAME>(emp_id NUMBERCONSTRAINT pk_emp_id PRIMARY KEY USING INDEX(CREATE INDEX <OWNER>.emp_id_ix ON <OWNER>.<TABLE_NAME>(emp_id)TABLESPACE indx),ename VARCHAR2(12),sal   number);Table created.SQL> select index_name,uniqueness from dba_indexes where table_name='<TABLE_NAME>';INDEX_NAME                     UNIQUENES------------------------------ ---------EMP_ID_IX                      NONUNIQUESQL> select constraint_name,index_name, constraint_type from dba_constraintswhere table_name='<TABLE_NAME>' and constraint_type='P';CONSTRAINT_NAME                INDEX_NAME                     C------------------------------ ------------------------------ -PK_EMP_ID                      EMP_ID_IX                      P-------------------------------------------------------------------------
Case 2: Create constraint and index implicitely within the same statement
-------------------------------------------------------------------------SQL> drop table <OWNER>.<TABLE_NAME>
Table dropped.SQL> create table <OWNER>.<TABLE_NAME>(emp_id NUMBERCONSTRAINT pk_emp_id PRIMARY KEY USING INDEX TABLESPACE indx,ename VARCHAR2(12),sal   number);Table created.SQL> select index_name,uniqueness from dba_indexes where table_name='<TABLE_NAME>';INDEX_NAME                     UNIQUENES------------------------------ ---------PK_EMP_ID                      UNIQUESQL> select constraint_name,index_name, constraint_type from dba_constraintswhere table_name='<TABLE_NAME>' and constraint_type='P';CONSTRAINT_NAME                INDEX_NAME                     C------------------------------ ------------------------------ -PK_EMP_ID                      PK_EMP_ID                      P--------------------------------------------------------------------
Case 3: Create constraint and index separately within two statements
--------------------------------------------------------------------SQL> drop table <OWNER>.<TABLE_NAME>
Table dropped.SQL> create table <OWNER>.<TABLE_NAME>(emp_id NUMBERCONSTRAINT pk_emp_id PRIMARY KEY  DISABLE,ename VARCHAR2(12),sal   number);Table created.SQL> create index <OWNER>.emp_id_ix on <OWNER>.<TABLE_NAME>(emp_id)tablespace indx;
Index created.SQL> select index_name,uniqueness from dba_indexes where table_name='<TABLE_NAME>';INDEX_NAME                     UNIQUENES------------------------------ ---------EMP_ID_IX                      NONUNIQUESQL> select constraint_name,index_name, constraint_type from dba_constraintswhere table_name='<TABLE_NAME>' and constraint_type='P';CONSTRAINT_NAME                INDEX_NAME                     C------------------------------ ------------------------------ -PK_EMP_ID                                                     PSQL> alter table <OWNER>.<TABLE_NAME> ENABLE constraint pk_emp_id;
Table altered.SQL> select index_name,uniqueness from dba_indexes where table_name='<TABLE_NAME>';INDEX_NAME                     UNIQUENES------------------------------ ---------EMP_ID_IX                      NONUNIQUESQL> select constraint_name,index_name, constraint_type from dba_constraintswhere table_name='<TABLE_NAME>' and constraint_type='P';CONSTRAINT_NAME                INDEX_NAME                     C------------------------------ ------------------------------ -PK_EMP_ID                      EMP_ID_IX                      PB. Disabling PK/UNIQUE constraints: what happens to the associated index ---------------------------------------------------------------------In Case 1 where the index was created explicitely within the same statementas the constraint, the index is in both cases disassociated from the constraint; depending on the clause "CASCADE DROP INDEX" usage, the index is dropped or not.In traditionnal Case 2, the behavior remains the same: using the clause "CASCADE DROP INDEX" or not does not influence the usual behavior: it automatically drops the relying index.In case 3, disabling the constraint drops the index or not: * if the constraint has never been enabled, it never drops the index.* but in most cases, the constraint has been enabled for some time. In this case, the clause "CASCADE DROP INDEX" drops the index.+-----------------+       +------------+| DBA_CONSTRAINTS |       | DBA_INDEXES|+-----------------+       +------------+-----------------------------   ------------Constraint_name   Index_name     Index_name--------------- -------------   ------------
Case 1: ALTER TABLE ... DISABLE PK     PK_EMP_ID         -             -        CASCADE DROP INDEX;orALTER TABLE ... DISABLE PK;    PK_EMP_ID         -         EMP_ID_IX    Case 2: ALTER TABLE ... DISABLE PK     PK_EMP_ID         -             -       CASCADE DROP INDEX;or ALTER TABLE ... DISABLE PK;    PK_EMP_ID         -             -      Case 3: ALTER TABLE ... DISABLE PK     PK_EMP_ID         -             -    CASCADE DROP INDEX;or ALTER TABLE ... DISABLE PK;    PK_EMP_ID         -         EMP_ID_IXC. Dropping PK/UNIQUE constraints: what happens to the associated index ---------------------------------------------------------------------In Case 1, where the index was created explicitely within the same statementas the constraint, the index is by default KEPT when the constraint is dropped.If you want the index to be dropped, you have to explicitely ask for it through the "DROP INDEX" clause.In case 2, the behavior is the opposite: if you want the index to be kept and the constraint dropped, you have to explicitly ask for it with the "KEEP INDEX" clause; otherwise the index is DROPPED by default.In Case 3, dropping the constraint drops the index or not: * if the constraint has never been enabled, it never drops the index.* but in most cases, the constraint has been enabled for some time. Then the index is by default KEPT when the constraint is dropped. If you want the index to be dropped, you have to explicitly ask for it with the "DROP INDEX" clause.+-----------------+   +-----------+| DBA_CONSTRAINTS |   |DBA_INDEXES|+-----------------+   +-----------+----------------------- ------------Constraint  Index_name   Index_name----------- ----------- ------------
Case 1: ALTER TABLE ... DROP PK DROP INDEX;     -            -           -       
Case 1: ALTER TABLE ... DROP PK KEEP INDEX;     -            -       EMP_ID_IX              
Case 1: ALTER TABLE ... DROP PK;                -            -       EMP_ID_IX   Case 2: ALTER TABLE ... DROP PK DROP INDEX;     -            -           -                                                      
Case 2: ALTER TABLE ... DROP PK KEEP INDEX;     -            -       PK_EMP_ID                                                              
Case 2: ALTER TABLE ... DROP PK;                -            -           -       Case 3: ALTER TABLE ... DROP PK DROP INDEX;     -            -           -   
Case 3: ALTER TABLE ... DROP PK KEEP INDEX;     -            -       EMP_ID_IX   
Case 3: ALTER TABLE ... DROP PK;                -            -       EMP_ID_IX

相关文章:

PK Nounique CASCADE DROP INDEX keep index

Explicit Control Over Indexes when Creating, Disabling, or Dropping PK/Unique Constraints (Doc ID 139666.1)​编辑To Bottom PURPOSEIn Oracle 9i, the DBA has an explicit control over how indexes are affectedwhile creating, disabling, or dropping Primary Ke…...

【Antd】实现Table组件行点击,解决某一列不触发行点击

今天有个新需求&#xff0c;点击table行&#xff0c;执行一些操作。实现过程中遇到了&#xff1a;点击操作列、操作列内按钮会冒泡触发行点击。antd版本&#xff1a;1.7.8 一、解决方案 customRow <a-table :customRow"handleClickRow" :data-source"data_li…...

Kafka3.0.0版本——Broker( 退役旧节点)示例

目录 一、服务器信息二、先启动4台zookeeper&#xff0c;再启动4台kafka三、通过PrettyZoo工具验证启动的kafka是否ok四、查看4台kafka集群节点上是否存在创建的名称为news的主题五、退役旧节点5.1、执行负载均衡操作5.2、 执行停止命令5.3、再次查看kafka中的创建过的名称为ne…...

【Rust】Rust学习 第十二章一个 I/O 项目:构建一个命令行程序

本章既是一个目前所学的很多技能的概括&#xff0c;也是一个更多标准库功能的探索。我们将构建一个与文件和命令行输入/输出交互的命令行工具来练习现在一些你已经掌握的 Rust 技能。 Rust 的运行速度、安全性、单二进制文件输出和跨平台支持使其成为创建命令行程序的绝佳选择…...

【MySQL--->表的操作】

文章目录 [TOC](文章目录) 一、创建表二、查看表三、修改表四、删除表drop table 表名; ![在这里插入图片描述](https://img-blog.csdnimg.cn/15227b8335364d41bd01b4b4dd83ee55.png) 一、创建表 语句格式:create table 表名(列名 类型,…)字符集 校验规则 存储引擎;字符集和校…...

PyTorch从零开始实现ResNet

文章目录 代码实现参考 代码实现 本文实现 ResNet原论文 Deep Residual Learning for Image Recognition 中的50层&#xff0c;101层和152层残差连接。 代码中使用基础残差块这个概念&#xff0c;这里的基础残差块指的是上图中红色矩形圈出的内容&#xff1a;从上到下分别使用…...

企业微信 企业内部开发 学习笔记

官方文档 文档 术语介绍 引入pom <dependency><groupId>com.github.binarywang</groupId><artifactId>wx-java-cp-spring-boot-starter</artifactId><version>4.5.3.B</version></dependency>核心代码 推送消息 final WxCp…...

03 QT基本控件和功能类

一 进度条 、水平滑动条 垂直滑动条 当在QT中,在已知类名的情况下,要了解类的构造函数 常用属性 及 信号和槽 常用api 特征:可以获取当前控件的值和设置它的当值 ---- int ui->progressBar->setValue(value); //给进度条设置一个整型值 ui->progressBar->value…...

epoll数据结构

目录 1.大量的fd 集合。选择什么数据结构&#xff1f;2、Epoll 数据结构Epitem 的定义Eventpoll 的定义 1.大量的fd 集合。选择什么数据结构&#xff1f; 查找频率很高的数据结构 1.红黑树 2.哈希&#xff08;扩容缩容&#xff09; 3. b/btree &#xff08;降低树的高度&#…...

LINUX学习笔记_GIT操作命令

LINUX学习笔记 GIT操作命令 基本命令 git init&#xff1a;初始化仓库git status&#xff1a;查看文件状态git add&#xff1a;添加文件到暂存区&#xff08;index&#xff09;git commit -m “注释”&#xff1a;提交文件到仓库&#xff08;repository&#xff09;git log&a…...

第一百二十九天学习记录:数据结构与算法基础:栈和队列(中)(王卓教学视频)

栈的表示和实现 顺序栈的初始化 ##入栈 链栈的表示...

C语言 — qsort 函数

介绍&#xff1a;qsort是一个库函数&#xff0c;用来对数据进行排序&#xff0c;可以排序任意类型的数据。 void qsort &#xff08;void*base&#xff0c; size_t num, size_t size, int(*compart)(const void*,constvoid*) &#xff09; qsort 具有四个参数&#xff1a; …...

开放式耳机哪个好一点?推荐几款优秀的开放式耳机

在追求更广阔的音场和更真实的音质时&#xff0c;开放式耳机是绝对值得考虑的选择。它们以其通透感和自然的音质而备受推崇&#xff0c;带来更逼真的音乐体验。下面我来推荐几款优秀的开放式耳机&#xff0c;满足你对音质和舒适度的要求&#xff0c;可尽情享受音乐的魅力。 一…...

vue-cli前端工程化——创建vue-cli工程 router版本的创建 目录结构 案例初步

目录 引出创建vue-cli前端工程vue-cli是什么自动构建创建vue-cli项目选择Vue的版本号 手动安装进行选择创建成功 手动创建router版多了一个router 运行测试bug解决 Vue项目结构main.jspackage.jsonvue.config.js Vue项目初步hello案例 总结 引出 1.vue-cli是啥&#xff0c;创建…...

Go和Java实现外观模式

Go和Java实现外观模式 下面我们通过一个构造各种形状的案例来说明外观模式的使用。 1、外观模式 外观模式隐藏系统的复杂性&#xff0c;并向客户端提供了一个客户端可以访问系统的接口。这种类型的设计模式属于结构型 模式&#xff0c;它向现有的系统添加一个接口&#xff…...

人工智能(一)基本概念

人工智能之基本概念 常见问题什么是人工智能&#xff1f;人工智能应用在那些地方&#xff1f;人工智能的三种形态图灵测试是啥&#xff1f;人工智能、机器学习和深度学习之间是什么关系&#xff1f;为什么人工智能计算会用到GPU&#xff1f; 机器学习什么是机器学习&#xff1f…...

〔AI 绘画〕Stable Diffusion 之 解决绘制多人或面部很小的人物时面部崩坏问题 篇

✨ 目录 &#x1f388; 脸部崩坏&#x1f388; 下载脸部修复插件&#x1f388; 启用脸部修复插件&#x1f388; 插件生成效果&#x1f388; 插件功能详解 &#x1f388; 脸部崩坏 相信很多人在画图时候&#xff0c;特别是画 有多个人物 图片或者 人物在图片中很小 的时候&…...

初步认识OSI/TCP/IP一(第三十八课)

1 初始OSI模型 OSI参考模型(Open Systems Interconnection Reference Model)是一个由国际标准化组织(ISO)和国际电报电话咨询委员会(CCITT)联合制定的网络通信协议规范,它将网络通信分为七个不同的层次,每个层次负责不同的功能和任务。 2 网络功能 数据通信、资源共享…...

英伟达结构化剪枝工具Nvidia Apex Automatic Sparsity [ASP](2)——代码分析

伟达结构化剪枝工具Nvidia Apex Automatic Sparsity [ASP]&#xff08;2&#xff09;——代码分析 ASP整个模块的结果如下&#xff1a; . ├── COPYRIGHT ├── README.md ├── __init__.py ├── asp.py ├── permutation_lib.py ├── permutation_search_kernels…...

FileNotFoundError: [WinError 2] 系统找不到指定的文件。

pyspark demo程序创建spark上下文 完整报错如下&#xff1a; sc SparkContext(“local”, “Partition ID Example”) File “C:\ProgramData\anaconda3\envs\python36\lib\site-packages\pyspark\context.py”, line 133, in init SparkContext._ensure_initialized(self, ga…...

CCF推荐C类会议与期刊全景解析:计算机网络研究者的学术地图

1. CCF推荐C类会议与期刊&#xff1a;计算机网络研究者的学术指南针 刚进入计算机网络领域的研究生常常会面临一个困惑&#xff1a;面对海量的学术会议和期刊&#xff0c;到底该从哪里入手&#xff1f;中国计算机学会&#xff08;CCF&#xff09;推荐的C类会议和期刊就像一张精…...

用STM32CubeMX配置PWM捕获:从定时器选型到串口输出全流程

STM32CubeMX实战&#xff1a;PWM捕获全流程解析与调试技巧 在嵌入式开发中&#xff0c;精确测量PWM信号的周期和占空比是常见需求。本文将带你从零开始&#xff0c;使用STM32CubeMX和HAL库完成PWM捕获功能的完整实现。不同于简单的教程复制&#xff0c;我们会深入探讨两种捕获…...

一款实用汉化工具快速安装使用指南 -- cheat-engine中文版安装教程入口

文章目录安装方式安装后在哪里找到&#xff1f;&#xff08;重点补全&#xff09;使用说明温馨提示首先呢&#xff0c;大家可能在用 cheat engine (CE修改器&#xff09;的时候呢&#xff0c;可能总是使用的是英文版&#xff0c;用的不太舒服啊&#xff0c;这个时候呢&#xff…...

新手福音:在快马平台交互式学习openclaw更新命令语法与参数

作为一名刚接触openclaw的新手&#xff0c;我最初看到那些复杂的命令行参数时简直一头雾水。直到发现了InsCode(快马)平台&#xff0c;它用可视化的方式帮我拆解了openclaw更新命令的每个细节&#xff0c;现在终于能自信地操作了。下面分享我的学习心得&#xff1a; 命令结构拆…...

镜像视界|从“静态建模”到“动态空间”:三维重构的终极形态——融合视频流建模与轨迹连续计算的空间智能引擎

镜像视界&#xff5c;从“静态建模”到“动态空间”&#xff1a;三维重构的终极形态——融合视频流建模与轨迹连续计算的空间智能引擎一、问题提出&#xff1a;为什么“建模”始终停留在静态在数字孪生、三维GIS与智慧城市系统中&#xff0c;“建模”一直是核心基础能力。 通过…...

基于MATLAB的智能车牌识别模型:实现定位、分割与识别一体化解决方案

基于MATLAB的车牌识别模型。 包括车牌识别系统&#xff0c;完成车牌定位、车牌字符分割和车牌字符识别。 用到灰度化、图像增强、边缘检测、车辆定位、分割车牌、车辆预处理、字符分割最后得到识别结果。 程序已调通&#xff0c;可直接运行。直接上干货&#xff01;今天带大家用…...

效率提升300%:OpenClaw+Phi-3-vision-128k-instruct重构我的学术工作流

效率提升300%&#xff1a;OpenClawPhi-3-vision-128k-instruct重构我的学术工作流 1. 从手动到自动的学术工作流革命 作为一名每天需要处理大量文献、实验数据和演示材料的科研工作者&#xff0c;我曾经花费近40%的工作时间在重复性文档处理上——截图标注、图表整理、笔记归…...

OpenClaw龙虾推出官方中国镜像站,由字节跳动提供支持

文章目录前言龙虾是谁&#xff1f;为啥它搞个镜像站这么重要&#xff1f;中国镜像站来了&#xff1a;地址是 mirror-cn.clawhub.com背后的故事&#xff1a;腾讯、字节、龙虾的"三国演义"镜像站的意义&#xff1a;不只是个"加速器"怎么用&#xff1f;手把手…...

【飞机】倾转旋翼飞机齿轮箱建模与Matlab仿真(含非线性阻尼和立方摩擦效应)

✅作者简介&#xff1a;热爱科研的Matlab仿真开发者&#xff0c;擅长毕业设计辅导、数学建模、数据处理、建模仿真、程序设计、完整代码获取、论文复现及科研仿真。&#x1f34e; 往期回顾关注个人主页&#xff1a;Matlab科研工作室&#x1f447; 关注我领取海量matlab电子书和…...

深度学习框架YOLOV8模型如何训练水下生物检测数据集 构建基于YOLOv8➕pyqt5的水下生物检测系统 海胆‘, ‘海参‘, ‘扇贝‘, ‘海星‘, ‘水草

享基于YOLOv8➕pyqt5的水下生物检测系统内含7600张水下生物数据集 包括[‘海胆’, ‘海参’, ‘扇贝’, ‘海星’, ‘水草’]&#xff0c;5类也可自行替换模型&#xff0c;使用该界面做其他检测 这是一个非常经典的计算机视觉应用项目&#xff0c;结合了深度学习的目标检测&…...