儲存管理之段收縮、可恢復空間
表空間的使用情況監控:
SQL> select tablespace_name,sum(bytes)/1024/1024 "free(M)" from dba_free_space g
roup by tablespace_name;
TABLESPACE_NAME free(M)
------------------------------ ----------
UNDOTBS1 284.9375
SYSAUX 14.5625
USERS 4.375
SYSTEM 6.5
EXAMPLE 22.3125
擴充套件users表空間到100m
SQL> alter database datafile 4 resize 100m;
資料庫已更改。
SQL>
SQL> select tablespace_name,sum(bytes)/1024/1024 "free(M)" from dba_free_space g
roup by tablespace_name;
TABLESPACE free(M)
---------- ----------
UNDOTBS1 284.9375
SYSAUX 14.5625
USERS 94.375
SYSTEM 6.5
EXAMPLE 22.3125
建立T1表,插入資料,檢視錶空間變化
SQL> create table t1 as select * from dba_objects;
表已建立。
SQL> insert into t1 select * from t1;
已建立50646行。
SQL> select tablespace_name,sum(bytes)/1024/1024 "free(M)" from dba_free_space g
roup by tablespace_name;
TABLESPACE free(M)
---------- ----------
UNDOTBS1 284.9375
SYSAUX 14.5625
USERS 82.375
SYSTEM 6.5
EXAMPLE 22.3125
段收縮測試:
SQL> select table_name,blocks from user_tables where table_name='T1';
TABLE_NAME BLOCKS
------------------------------ ----------
T1
收集統計資訊
SQL> exec dbms_stats.gather_table_stats('SCOTT','T1');
PL/SQL 過程已成功完成。
SQL> select table_name,blocks from user_tables where table_name='T1';
TABLE_NAME BLOCKS
------------------------------ ----------
T1 1524
啟動行移動
SQL> alter table t1 enable row movement;
表已更改。
刪除5000行資料,檢視錶的塊數量
SQL> delete from t1 where rownum<50000;
已刪除49999行。
SQL> select table_name,blocks from user_tables where table_name='T1';
TABLE_NAME BLOCKS
------------------------------ ----------
T1 1524
此時沒有改變,即使收集統計資訊後,也沒有改變,因為刪除並不釋放資料塊
SQL> exec dbms_stats.gather_table_stats('SCOTT','T1');
PL/SQL 過程已成功完成。
SQL> select table_name,blocks from user_tables where table_name='T1';
TABLE_NAME BLOCKS
------------------------------ ----------
T1 1524
然後進行段收縮操作
SQL> alter table t1 shrink space ;
表已更改。
SQL> select table_name,blocks from user_tables where table_name='T1';
TABLE_NAME BLOCKS
------------------------------ ----------
T1 1524
SQL> exec dbms_stats.gather_table_stats('SCOTT','T1');
PL/SQL 過程已成功完成。
SQL> select table_name,blocks from user_tables where table_name='T1';
TABLE_NAME BLOCKS
------------------------------ ----------
T1 706
這樣發現塊數量減少到了706達到了釋放塊的目的
管理可恢復空間
建立不能自動擴充套件的表空間
SQL> create tablespace test datafile 'd:\test.dbf' size 1m
2 /
表空間已建立。
SQL> create table tt as select * from user_tables;
表已建立。
SQL> alter table tt move tablespace test;
表已更改。
SQL> insert into tt select * from tt;
已建立5行。
SQL> insert into tt select * from tt;
已建立10行。
SQL> insert into tt select * from tt;
已建立20行。
SQL> insert into tt select * from tt;
已建立40行。
SQL> insert into tt select * from tt;
已建立80行。
SQL> insert into tt select * from tt;
已建立160行。
SQL> insert into tt select * from tt;
已建立320行。
SQL> insert into tt select * from tt;
已建立640行。
SQL> insert into tt select * from tt;
已建立1280行。
SQL> insert into tt select * from tt;
insert into tt select * from tt
*
第 1 行出現錯誤:
ORA-01653: unable to extend table SCOTT.TT by 8 in tablespace TEST
此時沒有開啟可恢復功能,於是該操作將被回滾掉
然後開啟可恢復功能
SQL> commit;
提交完成。
SQL> alter session enable resumable;
會話已更改。
SQL> insert into tt select * from tt;
這時發現這個插入操作將被掛起
在另一個session,檢視test.dbf的檔案號
SQL> col file_name format a50;
SQL> select file_name,file_id from dba_data_files;
FILE_NAME FILE_ID
-------------------------------------------------- ----------
F:\ORACLE\PRODUCT\10.2.0\DB_1\ORADATA\ORCL\USERS01 4
.DBF
F:\ORACLE\PRODUCT\10.2.0\DB_1\ORADATA\ORCL\SYSAUX0 3
1.DBF
F:\ORACLE\PRODUCT\10.2.0\DB_1\ORADATA\ORCL\UNDOTBS 2
01.DBF
F:\ORACLE\PRODUCT\10.2.0\DB_1\ORADATA\ORCL\SYSTEM0 1
1.DBF
FILE_NAME FILE_ID
-------------------------------------------------- ----------
F:\ORACLE\PRODUCT\10.2.0\DB_1\ORADATA\ORCL\EXAMPLE 5
01.DBF
D:\TEST.DBF 6
已選擇6行。
將test.dbf擴充套件到10M
SQL> alter database datafile 6 resize 10m;
資料庫已更改。
然後回到之前的session
SQL> insert into tt select * from tt;
已建立2560行。
掛起的操作此時完成了
另外可以設定掛起時間,10秒
SQL> alter session enable resumable timeout 10;
會話已更改。
。。。。。。
然後掛起10秒後,還沒有處理該問題就報錯
SQL> insert into tt select * from tt;
已建立5120行。
SQL>
SQL> insert into tt select * from tt;
已建立10240行。
SQL> insert into tt select * from tt;
insert into tt select * from tt
*
第 1 行出現錯誤:
ORA-30032: the suspended (resumable) statement has timed out
ORA-01653: unable to extend table SCOTT.TT by 128 in tablespace TEST
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24104518/viewspace-712745/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 資料庫恢復中需要大量儲存空間的原因HQ資料庫
- SYSTEM 表空間管理及備份恢復
- Oracle表空間收縮方案Oracle
- mysql收縮共享表空間MySql
- lvm收縮邏輯卷空間LVM
- Android Activity 重建之狀態儲存與恢復Android
- 【儲存資料恢復】NetApp儲存誤刪除的資料恢復案例資料恢復APP
- Oracle RMAN 表空間恢復Oracle
- MySQL 5.7新特性之線上收縮undo表空間MySql
- 【儲存資料恢復】EqualLogic PS系列儲存磁碟故障的資料恢復案例資料恢復
- 【伺服器儲存資料恢復】HP-Lefthand儲存資料恢復案例伺服器資料恢復
- 【儲存資料恢復】某品牌EqualLogic系列儲存介紹和資料恢復方法資料恢復
- 【儲存資料恢復】HP EVA儲存誤刪除VDISK的資料恢復案例資料恢復
- 【儲存資料恢復】NetApp儲存誤刪資料夾的資料恢復案例資料恢復APP
- 表空間TSPITR恢復-實驗
- 【Oracle 恢復表空間】 實驗Oracle
- 【VSAN資料恢復】VSAN儲存資料恢復案例資料恢復
- Win10系統管理磁碟儲存空間的方法Win10
- 用flashback恢復儲存過程儲存過程
- VSAN儲存結構解析+儲存資料恢復案例資料恢復
- Impala之儲存和壓縮
- 【儲存資料恢復】H3C FlexStorage儲存卷被刪如何恢復資料?資料恢復Flex
- 2、儲存容量和儲存地址空間的轉換
- innodb表空間儲存結構
- 【RESIZE】Oracle收縮表空間主要命令Oracle
- 小儲存容量手機有救了!Android 新歸檔功能可釋放 60% 儲存空間Android
- 【伺服器資料恢復】儲存伺服器之間遷移資料時資料丟失恢復成功案例伺服器資料恢復
- 【儲存資料恢復】IBM儲存檔案NTFS系統損壞的資料恢復案例資料恢復IBM
- WD MYbook儲存硬碟資料恢復硬碟資料恢復
- (Les16 執行資料庫恢復)-表空間恢復資料庫
- 【儲存資料恢復】EMC某型號儲存raid5崩潰的資料恢復案例資料恢復AI
- 【儲存資料恢復】儲存上的raid5陣列崩潰的資料恢復案例資料恢復AI陣列
- EMC 儲存資料恢復案例詳解【資料恢復方案】資料恢復
- Vsan資料恢復—Vsan分散式儲存資料恢復案例資料恢復分散式
- 儲存崩潰資料恢復過程;資料恢復案例資料恢復
- 表空間(資料檔案shrink)收縮示例
- mysql共享表空間擴容,收縮,遷移MySql
- 8. Oracle日常管理——8.1. OS日常管理——8.1.2. OS儲存空間Oracle
- 儲存刪除資料後恢復方法-適用netAPP儲存APP