set unused的用法(ORACLE删除字段)
set unused的用法(ORACLE删除字段)
一、问题
现场有一张大数据量的分区表,数据量在10G以上。因某种原因需要删除其中的某些字段。如果直接用
alter table1 drop (column1,column2);
或者alter table1 drop column column1;和alter table1 drop column column2;
的话,需要执行很长时间,这期间该表被锁,会影响到其它应用。
二、解决方法
使用set unused,等系统空闲时再drop unused。
1.
alter table table1 set unused (column1,column2);
或者
alter table table1 set unused column column1;
alter table table2 set unused column column2;
2.
alter table drop unused columns checkpoint 1000;
三、知识点(set unused的用法)
原理:清楚掉字典信息(撤消存储空间),不可恢复。
可以使用 SET UNUSED 选项标记一列或者多列不可用。
使用DROP SET UNUSED 选项删除被标记为不可用的列。
语法:
ALTER TABLE table SET UNUSED (COLlist多个) 或者 ALTER TABLE table SET UNUSED COLUMN col单个;
ALTER TABLE table DROP UNUSED COLUMNS [checkpoint 1000];
set unused不会真地删除字段。
除了alter table drop field外,也可以
alter table set unused field;
alter table drop unused;
set unused系统开销比较小,速度较快,所以可以先set unused,然后在系统负载较小时,再drop。如系统负载不大,也可以直接drop。
不管用何种方法,都不会收回空间。
如果你有这个需求,要删除某一个表上的某些列,但是由于这个表拥有非常大量的资料,如果你在尖峰时间直接执行 ALTER TABLE ABC DROP(COLUMN);可能会收到
ORA-01562 - failed to extend rollback segment number string,
这是因为在这个删除列的过程中你可能会消耗光整个RBS,造成这样的错误出现,因此这样的做法并不是一个好方法,就算你拼命的加大RBS空间来应付这个问题,也不会是个好主意。
我的建议做法:
1>
CREATE TABLE T1 (A NUMBER,B NUMBER);
SQL> begin
2 for i in 1 …… 100000
3 loop
4 insert into t1 values (i,100);
5 end loop;
6 commit;
7 end;
SQL> select count(*) from t1;
set unused的用法(ORACLE删除字段)的更多相关文章
- ORACLE删除字段(set unused的用法)
一.问题 现场有一张大数据量的分区表,数据量在10G以上.因某种原因需要删除其中的某些字段.如果直接用 alter table1 drop (column1,column2); 或者alter tab ...
- oracle删除字段中的空格、回车及指定字符
create or replace procedure PROC_test is --Description:删除字段中的指定字符(回车chr(13).换行chr(10)) --By LiChao - ...
- oracle删除字段时候判断字段是否存在
declare v_count number; begin ) into v_count from all_tab_columns a where a.TABLE_NAME = 'XXX1' and ...
- oracle 删除字段中空格
update sales_report set region = REGEXP_REPLACE(region, '( ){1,}', '')
- Oracle 增加修改删除字段
Oracle 增加修改删除字段 添加字段的语法:alter table tablename add (column datatype [default value][null/not null],…. ...
- oracle删除表字段和oracle表增加字段
这篇文章主要介绍了oracle表增加字段.删除表字段修改表字段的使用方法,大家参考使用吧 添加字段的语法:alter table tablename add (column datatype [d ...
- Oracle SET UNUSED的用法
SET UNUSED的用法 原理:清楚掉字典信息(撤消存储空间),不可恢复. 可以使用 SET UNUSED选项标记一列或者多列不可用. 使用DROP SET UNUSED选项删除被被标记 ...
- Oracle删除修改字段
Oracle 增加修改删除字段 添加字段的语法:alter table tablename add (column datatype [default value][null/not null],…. ...
- Oracle 增加修改删除字段与添加注释
添加字段的语法:alter table tablename add (column datatype [default value][null/not null],….); 修改字段的语法:alter ...
随机推荐
- to do list_hadoop
1.页面翻译 2.UI优化 vue.js reactive.js 3.Hadoop生态学习 Spark.Kafka.Druid……
- SpringBoot学习(二)
spring-boot-starter-parent Maven的用户可以通过继承spring-boot-starter-parent项目来获得一些合理的默认配置.这个parent提供了以下特性: 默 ...
- Terminal run py文件
cd Documents cd PythonCode python3 hello.py Text Editor: Atom Atom 可以用来写 python 脚本 (文件后缀名 .py). 但是不用 ...
- 前端面试题 | JS部分(附带答案)
目前在找工作,所以各方收集了一堆面试题.其实刷面试题的过程也能更新自己对知识的认识,所以也提醒自己多看多理解.如果对下面题目有更深理解,会实时更新.遇到新题目,也会不定时更新.希望能帮助到部分朋友- ...
- java复制文件夹中的所有文件和文件夹到另一个文件夹中
1.复制文件夹 public static void copyDir(String oldPath, String newPath) throws IOException { File file = ...
- ADO.NET DBHelper
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Da ...
- WinForm 拖动、移动窗体
private const int WM_NCLBUTTONDOWN = 0XA1; private const int HTCAPTION = 2; [System.Runtime.InteropS ...
- Educational Codeforces Round 23 F. MEX Queries 离散化+线段树
F. MEX Queries time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...
- 使用ajax无法跨源问题总结
参考文章: 浏览器同源政策及其规避方法 跨域资源共享 CORS 详解 使用jQuery实现跨域提交表单数据 <form action="http://v.juhe.cn/weather ...
- 关于UTC时间和本地时间
收藏了个类Publics 可以实现本地时间和UTC时间的转换 UCT时间=本地时间-8 本地时间比UTC时间快8小时 element-ui的日期选择器上 选择的时间显示的是本地时间 但实 ...