结论
1,alter table drop unused columns checkpoint适用于减少不必要的undo空间消耗
2,checkpoint选项可取值有:
不取值,默认在512条记录后发生检查点动作
大于表记录个数,表明在处理完所有表记录后发生检查点
小于表记录个数,表明在指定表记录后发生检查点
3,如果checkpoint选项后产生的检查点动作被中断,仅truncate table,drop table,alter table drop unused columns continue语句可以运行
4,alter table drop unused columns continue即恢复继续执行被中断的alter table drop unused columns checkpoint继续下去
测试
1,数据库版本
SQL> select * from v$version where rownum=1;
BANNER
----------------------------------------------------------------------------------------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
2,开启检查点信息到告警日志
SQL> show parameter checkpoint
NAME TYPE VALUE
------------------------------------ ---------------------- ------------------------------
log_checkpoint_interval integer 0
log_checkpoint_timeout integer 1800
log_checkpoints_to_alert boolean FALSE
SQL> alter system set log_checkpoints_to_alert=true;
System altered.
[oracle@seconary trace]$ tail -f alert_guowang.log
Current log# 2 seq# 356 mem# 0: /oracle/oradata/guowang/redo02.log
Fri Oct 16 08:18:16 2015
Thread 1 advanced to log sequence 357 (LGWR switch)
Current log# 3 seq# 357 mem# 0: /oracle/oradata/guowang/redo03.log
Fri Oct 16 08:27:17 2015
ALTER SYSTEM SET log_checkpoints_to_alert=TRUE SCOPE=BOTH;
Fri Oct 16 08:28:44 2015
Beginning log switch checkpoint up to RBA [0x166.2.10], SCN: 11696352
Thread 1 advanced to log sequence 358 (LGWR switch)
Current log# 1 seq# 358 mem# 0: /oracle/oradata/guowang/redo01.log
SQL> alter system checkpoint;
System altered.
Fri Oct 16 08:29:15 2015
Beginning global checkpoint up to RBA [0x166.1044.10], SCN: 11698731
Completed checkpoint up to RBA [0x166.1044.10], SCN: 11698731
Completed checkpoint up to RBA [0x166.2.10], SCN: 11696352
3,创建测试表并插入数据
SQL> conn scott/system
Connected.
SQL> create table t_checkpoint(a int,b int);
Table created.
SQL> insert into t_checkpoint select level,level from dual connect by level<=100000;
100000 rows created.
SQL> commit;
Commit complete.
4,指定测试表B列为不可用
SQL> alter table t_checkpoint set unused column b;
Table altered.
5,可见指定checkpoint选项后会发生一个检查点动作
SQL> alter table t_checkpoint drop unused columns checkpoint 500;
Table altered.
Fri Oct 16 08:34:11 2015
Beginning log switch checkpoint up to RBA [0x167.2.10], SCN: 11720087
Thread 1 advanced to log sequence 359 (LGWR switch)
Current log# 2 seq# 359 mem# 0: /oracle/oradata/guowang/redo02.log
6,如果正在进行检查点动作,被中断,会如何呢?
SQL> drop table t_checkpoint purge;
Table dropped.
SQL> create table t_checkpoint(a int,b int);
Table created.
SQL> insert into t_checkpoint select level,level from dual connect by level<=100000;
100000 rows created.
SQL> commit;
Commit complete.
SQL> alter table t_checkpoint drop unused columns checkpoint;
alter table t_checkpoint drop unused columns checkpoint
*
ERROR at line 1:
ORA-00604: error occurred at recursive SQL level 1
ORA-01013: user requested cancel of current operation
SQL> SQL>
SQL> select table_name,status from user_tables where table_name='T_CHECKPOINT';
TABLE_NAME STATUS
------------------------------------------------------------ ----------------
T_CHECKPOINT VALID
可见如果检查点进程被中断,不能进行alter table add操作,必须先要让检查点运行完成,即运行
alter table drop columns continue
SQL> alter table t_checkpoint add c int;
alter table t_checkpoint add c int
*
ERROR at line 1:
ORA-12986: columns in partially dropped state. Submit ALTER TABLE DROP COLUMNS
CONTINUE
SQL>
SQL> host oerr ora 12986
12986, 00000, "columns in partially dropped state. Submit ALTER TABLE DROP COLUMNS CONTINUE"
// *Cause: An attempt was made to access a table with columns in partially
// dropped state (i.e., drop column operation was interrupted).
// *Action: Submit ALTER TABLE DROP COLUMNS CONTINUE to complete the drop
// column operation before accessing the table.
select查询也不成
SQL> select count(*) from t_checkpoint;
select count(*) from t_checkpoint
*
ERROR at line 1:
ORA-12986: columns in partially dropped state. Submit ALTER TABLE DROP COLUMNS
CONTINUE
truncate操作是可以成功的
SQL> truncate table t_checkpoint;
Table truncated.
alter table drop columns continue用于继续执行被中断的检查点选项的删除列操作
SQL> alter table t_checkpoint drop columns continue;
Table altered.
SQL> alter table t_checkpoint add c int;
Table altered.
个人简介
8年oracle从业经验,具备丰富的oracle技能,目前在国内北京某专业oracle服务公司从事高级技术顾问。
服务过的客户:
中国电信
中国移动
中国联通
中国电通
国家电网
四川达州商业银行
湖南老百姓大药房
山西省公安厅
中国邮政
北京302医院
河北廊坊新奥集团公司
项目经验:
中国电信3G项目AAA系统数据库部署及优化
中国联通4G数据库性能分析与优化
中国联通CRM数据库性能优化
中国移动10086电商平台数据库部署及优化
湖南老百姓大药房ERR数据库sql优化项目
四川达州商业银行TCBS核心业务系统数据库模型设计和RAC部署及优化
四川达州商业银行TCBS核心业务系统后端批处理存储过程功能模块编写及优化
北京高铁信号监控系统RAC数据库部署及优化
河南宇通客车数据库性能优化
中国电信电商平台核心采购模块表模型设计及优化
中国邮政储蓄系统数据库性能优化及sql优化
北京302医院数据库迁移实施
河北廊坊新奥data guard部署及优化
山西公安厅身份证审计数据库系统故障评估
国家电网上海灾备项目4 node rac+adg
贵州移动crm及客服数据库性能优化项目
贵州移动crm及客服务数据库sql审核项目
深圳穆迪软件有限公司数据库性能优化项目
联系方式:
手机:18201115468
qq : 305076427
qq微博: wisdomone1
新浪微博:wisdomone9
qq群:275813900
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/9240380/viewspace-1814721/
,如需转载,请注明出处,否则将追究法律责任。