[20200423]12c删除不需要的记录.txt --//12CR2支持改动表仅仅包括需要的特定记录,删除不需要的记录。语法如下: --// alter table table_name move including rows where <query_where >. 1.环境: SCOTT@book> @ver1 PORT_STRING VERSION BANNER ------------------------------ -------------- -------------------------------------------------------------------------------- x86_64/Linux 2.4.xx 11.2.0.4.0 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production 2.测试: SCOTT@test01p> create table tx as select * from all_objects ; Table created. SCOTT@test01p> create unique index i_tx_object_id on tx(object_id); Index created. SCOTT@test01p> select count(*) from tx ; COUNT(*) ---------- 68135 SCOTT@test01p> select count(*) from tx where owner='SYS'; COUNT(*) ---------- 47452 --//仅仅需要保留owner='SYS'记录,理论删除其它redo消耗很大,以前常规方法是通过ctas或者物化视图方式建立新表替换旧表。 --//现在可以执行如下: SCOTT@test01p> alter table tx move online including rows where owner='SYS' UPDATE INDEXES; Table altered. SCOTT@test01p> select count(*) from tx ; COUNT(*) ---------- 47452 SCOTT@test01p> select object_name from tx where object_id=2; OBJECT_NAME -------------------- C_OBJ# SCOTT@test01p> @ dpc '' '' PLAN_TABLE_OUTPUT ------------------------------------- SQL_ID 8tw1qfk3y5ru2, child number 0 ------------------------------------- select object_name from tx where object_id=2 Plan hash value: 3474389346 ----------------------------------------------------------------------------------------------- | Id | Operation | Name | E-Rows |E-Bytes| Cost (%CPU)| E-Time | ----------------------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | | | 2 (100)| | | 1 | TABLE ACCESS BY INDEX ROWID| TX | 1 | 41 | 2 (0)| 00:00:01 | |* 2 | INDEX UNIQUE SCAN | I_TX_OBJECT_ID | 1 | | 1 (0)| 00:00:01 | ----------------------------------------------------------------------------------------------- Query Block Name / Object Alias (identified by operation id): ------------------------------------------------------------- 1 - SEL$1 / TX@SEL$1 2 - SEL$1 / TX@SEL$1 Predicate Information (identified by operation id): --------------------------------------------------- 2 - access("OBJECT_ID"=2) --//索引依旧有效。 This only moves the rows matching the where clause. Provided you want to remove a large chunk of data, this can be much faster than delete. And it has an online clause. So unlike the CTAS methods, you can do this while the application is still running. --//这种方式更加简单,不知道如果在原表上有DML,会出现什么情况,没有测试。至少一些维护会简单许多,我估计有点像 --//在线重定义使用物化视图的方式。
[20200423]12c删除不需要的记录.txt
来源:这里教程网
时间:2026-03-03 15:30:08
作者:
编辑推荐:
- [20200423]12c删除不需要的记录.txt03-03
- Oracle GoldenGate 11g官方文档Administrator’s Guide续一03-03
- oracle invisible index与unusable index的区别03-03
- [20200423]防水墙与v$open_cursor.txt03-03
- 利用shell脚本定时清理某个sql_id的session03-03
- Oracle 19C+13.4EMCC主机监控03-03
- [20200424]跟踪特定sql语句以及v$open_cursor视图(再补充).txt03-03
- 记录一次Oracle 11.2.0.4 RAC异地恢复到单实例03-03
下一篇:
相关推荐
-
雷神推出 MIX PRO II 迷你主机:基于 Ultra 200H,玻璃上盖 + ARGB 灯效
2 月 9 日消息,雷神 (THUNDEROBOT) 现已宣布推出基于英
-
制造商 Musnap 推出彩色墨水屏电纸书 Ocean C:支持手写笔、第三方安卓应用
2 月 10 日消息,制造商 Musnap 现已在海外推出一款 Oce
热文推荐
- Oracle GoldenGate 11g官方文档Administrator’s Guide续一
- Oracle 19C+13.4EMCC主机监控
Oracle 19C+13.4EMCC主机监控
26-03-03 - [20200424]跟踪特定sql语句以及v$open_cursor视图(再补充).txt
- Oracle 19C OGG基础运维-05DDL操作同步
Oracle 19C OGG基础运维-05DDL操作同步
26-03-03 - Oracle 19C OGG基础运维-06增加复制表
Oracle 19C OGG基础运维-06增加复制表
26-03-03 - Oracle 19C OGG基础运维-07减少复制表
Oracle 19C OGG基础运维-07减少复制表
26-03-03 - Oracle 19C OGG基础运维-08Error code [942]
- Oracle 19C OGG基础运维-09OGG-15121错误
Oracle 19C OGG基础运维-09OGG-15121错误
26-03-03 - 疫情后时代,招投标形势将如何?
疫情后时代,招投标形势将如何?
26-03-03 - 连载一:Oracle迁移文档大全
连载一:Oracle迁移文档大全
26-03-03
