alter table drop unused columns checkpoint
結論
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.
出自:
oracle 11g之alter table drop unused columns checkpoint刪除表不可用列系列二_ITPUB部落格
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/25583515/viewspace-2842045/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- alter table set unused column
- create table,show tables,describe table,DROP TABLE,ALTER TABLE ,怎麼使用?
- mysql的ALTER TABLE命令MySql
- drop apply INSTANTIATION for one tableAPP
- alter table move與shrink space
- alter table nologging /*+APPEND PARALLEL(n)*/APPParallel
- ocp 19c考題,科目082考試題(16)-about dropping and unused columns
- ALTER TABLE修改列的不同方法
- MySQL-ALTER TABLE命令學習[20180503]MySql
- [20191129]ALTER TABLE MINIMIZE RECORDS_PER_BLOCK.txtBloC
- 深入解析 oracle drop table內部原理Oracle
- ocp 19c考題,科目082考試題(22)- drop columns
- MySQL資料災難挽救之drop tableMySql
- [20181203]drop table後如何獲得表結構.txt
- oracle drop table purge無備份bbed恢復(3/3)Oracle
- oracle drop table purge無備份bbed恢復(1/3)Oracle
- oracle drop table purge無備份bbed恢復(2/3)Oracle
- 修改MySQL資料型別報 Changing columns for table XXX 錯的問題MySql資料型別
- 透過alter table 來實現重建表,同事大呼開眼界了
- MySQL alter table時執行innobackupex全備再看Seconds_Behind_MasterMySqlAST
- CSS columnsCSS
- MySQL中的alter table命令的基本使用方法及提速最佳化MySql
- Oracle 12.2之後ALTER TABLE .. MODIFY轉換非分割槽表為分割槽表Oracle
- 直接登入資料庫使用drop table tablename;會是什麼情況?資料庫
- Color Rows and Columns
- mysql checkpointMySql
- CSS3 columnsCSSS3
- Unused Block Compression和Null Block CompressionBloCNull
- MySQL ALTER命令MySql
- SQL__ALTERSQL
- F. Color Rows and Columns
- CSS columns 多列布局CSS
- Postgresql 的CheckpointSQL
- 線上改表工具oak-online-alter-table和pt-online-schema-change的使用限制總結
- mysql加快alter操作MySql
- JavaScript drop 事件JavaScript事件
- SQL__DROPSQL
- PostgreSQL備機checkpointSQL