shrink space 的整個過程就是在做delete和insert
shrink space 的整個過程就是在做delete和insert
SQL> select segment_name,bytes/1024/1024 from dba_segments where segment_name='TEST_SHRINK';
SEGMENT_NAME BYTES/1024/1024
-------------------- ---------------
TEST_SHRINK 300.375
SQL> delete test_shrink where rownum<100000;
99999 rows deleted.
SQL> commit;
Commit complete.
SQL> delete test_shrink where rownum<100000;
99999 rows deleted.
SQL> commit;
Commit complete.
SQL> select segment_name,bytes/1024/1024 from dba_segments where segment_name='TEST_SHRINK';
SEGMENT_NAME BYTES/1024/1024
-------------------- ---------------
TEST_SHRINK 300.375
SQL> select * from v$sesstat where sid =(select distinct sid from v$mystat) and statistic#=(select statistic# from v$statname where name='redo size');
SID STATISTIC# VALUE
---------- ---------- ----------
136 134 259857896
SQL> alter table test_shrink enable row movement;
Table altered.
SQL> alter table test_shrink shrink space;
Table altered.
SQL> select * from v$sesstat where sid =(select distinct sid from v$mystat) and statistic#=(select statistic# from v$statname where name='redo size');
SID STATISTIC# VALUE
---------- ---------- ----------
136 134 541072808
SQL> select segment_name,bytes/1024/1024 from dba_segments where segment_name='TEST_SHRINK';
SEGMENT_NAME BYTES/1024/1024
-------------------- ---------------
TEST_SHRINK 175.875
SQL>select * from v$locked_object
XIDUSN XIDSLOT XIDSQN OBJECT_ID SESSION_ID ORACLE_USERNAME OS_USER_NAME PROCESS
---------- ---------- ---------- ---------- ---------- ------------------------------ ------------------------------ ------------
LOCKED_MODE
-----------
9 4 145 10388 136 YXYUP oracle 11064
3
logminer日誌
QL> select operation,sql_redo from v$logmnr_contents;
OPERATION
--------------------------------
SQL_REDO
--------------------------------------------------------------------------------
DELETE
delete from "YXYUP"."TEST_SHRINK" where "OWNER" = 'SYS' and "OBJECT_NAME" = 'USE
R_QUEUE_PUBLISHERS' and "SUBOBJECT_NAME" IS NULL and "OBJECT_ID" = '4623' and "D
ATA_OBJECT_ID" IS NULL and "OBJECT_TYPE" = 'VIEW' and "CREATED" = TO_DATE('20-JA
N-07', 'DD-MON-RR') and "LAST_DDL_TIME" = TO_DATE('20-JAN-07', 'DD-MON-RR') and
"TIMESTAMP" = '2007-01-20:04:25:26' and "STATUS" = 'VALID' and "TEMPORARY" = 'N'
and "GENERATED" = 'N' and "SECONDARY" = 'N' and ROWID = 'AAACiUAAEAAANLOAAq';
INSERT
OPERATION
--------------------------------
SQL_REDO
--------------------------------------------------------------------------------
insert into "YXYUP"."TEST_SHRINK"("OWNER","OBJECT_NAME","SUBOBJECT_NAME","OBJECT
_ID","DATA_OBJECT_ID","OBJECT_TYPE","CREATED","LAST_DDL_TIME","TIMESTAMP","STATU
S","TEMPORARY","GENERATED","SECONDARY") values ('SYS','USER_QUEUE_PUBLISHERS',NU
LL,'4623',NULL,'VIEW',TO_DATE('20-JAN-07', 'DD-MON-RR'),TO_DATE('20-JAN-07', 'DD
-MON-RR'),'2007-01-20:04:25:26','VALID','N','N','N');
DELETE
delete from "YXYUP"."TEST_SHRINK" where "OWNER" = 'PUBLIC' and "OBJECT_NAME" = '
USER_QUEUE_PUBLISHERS' and "SUBOBJECT_NAME" IS NULL and "OBJECT_ID" = '4624' and
OPERATION
--------------------------------
SQL_REDO
--------------------------------------------------------------------------------
"DATA_OBJECT_ID" IS NULL and "OBJECT_TYPE" = 'SYNONYM' and "CREATED" = TO_DATE(
'20-JAN-07', 'DD-MON-RR') and "LAST_DDL_TIME" = TO_DATE('20-JAN-07', 'DD-MON-RR'
) and "TIMESTAMP" = '2007-01-20:04:25:26' and "STATUS" = 'VALID' and "TEMPORARY"
= 'N' and "GENERATED" = 'N' and "SECONDARY" = 'N' and ROWID = 'AAACiUAAEAAANLOA
Ar';
INSERT
insert into "YXYUP"."TEST_SHRINK"("OWNER","OBJECT_NAME","SUBOBJECT_NAME","OBJECT
_ID","DATA_OBJECT_ID","OBJECT_TYPE","CREATED","LAST_DDL_TIME","TIMESTAMP","STATU
OPERATION
--------------------------------
SQL_REDO
--------------------------------------------------------------------------------
S","TEMPORARY","GENERATED","SECONDARY") values ('PUBLIC','USER_QUEUE_PUBLISHERS'
,NULL,'4624',NULL,'SYNONYM',TO_DATE('20-JAN-07', 'DD-MON-RR'),TO_DATE('20-JAN-07
', 'DD-MON-RR'),'2007-01-20:04:25:26','VALID','N','N','N');
......................
可以看出shrink space 的整個過程都是在做delete和insert 操作,
感覺這個操作在生產DB不是逼不得已的時候,還是不用為好
SQL> select segment_name,bytes/1024/1024 from dba_segments where segment_name='TEST_SHRINK';
SEGMENT_NAME BYTES/1024/1024
-------------------- ---------------
TEST_SHRINK 300.375
SQL> delete test_shrink where rownum<100000;
99999 rows deleted.
SQL> commit;
Commit complete.
SQL> delete test_shrink where rownum<100000;
99999 rows deleted.
SQL> commit;
Commit complete.
SQL> select segment_name,bytes/1024/1024 from dba_segments where segment_name='TEST_SHRINK';
SEGMENT_NAME BYTES/1024/1024
-------------------- ---------------
TEST_SHRINK 300.375
SQL> select * from v$sesstat where sid =(select distinct sid from v$mystat) and statistic#=(select statistic# from v$statname where name='redo size');
SID STATISTIC# VALUE
---------- ---------- ----------
136 134 259857896
SQL> alter table test_shrink enable row movement;
Table altered.
SQL> alter table test_shrink shrink space;
Table altered.
SQL> select * from v$sesstat where sid =(select distinct sid from v$mystat) and statistic#=(select statistic# from v$statname where name='redo size');
SID STATISTIC# VALUE
---------- ---------- ----------
136 134 541072808
SQL> select segment_name,bytes/1024/1024 from dba_segments where segment_name='TEST_SHRINK';
SEGMENT_NAME BYTES/1024/1024
-------------------- ---------------
TEST_SHRINK 175.875
SQL>select * from v$locked_object
XIDUSN XIDSLOT XIDSQN OBJECT_ID SESSION_ID ORACLE_USERNAME OS_USER_NAME PROCESS
---------- ---------- ---------- ---------- ---------- ------------------------------ ------------------------------ ------------
LOCKED_MODE
-----------
9 4 145 10388 136 YXYUP oracle 11064
3
logminer日誌
QL> select operation,sql_redo from v$logmnr_contents;
OPERATION
--------------------------------
SQL_REDO
--------------------------------------------------------------------------------
DELETE
delete from "YXYUP"."TEST_SHRINK" where "OWNER" = 'SYS' and "OBJECT_NAME" = 'USE
R_QUEUE_PUBLISHERS' and "SUBOBJECT_NAME" IS NULL and "OBJECT_ID" = '4623' and "D
ATA_OBJECT_ID" IS NULL and "OBJECT_TYPE" = 'VIEW' and "CREATED" = TO_DATE('20-JA
N-07', 'DD-MON-RR') and "LAST_DDL_TIME" = TO_DATE('20-JAN-07', 'DD-MON-RR') and
"TIMESTAMP" = '2007-01-20:04:25:26' and "STATUS" = 'VALID' and "TEMPORARY" = 'N'
and "GENERATED" = 'N' and "SECONDARY" = 'N' and ROWID = 'AAACiUAAEAAANLOAAq';
INSERT
OPERATION
--------------------------------
SQL_REDO
--------------------------------------------------------------------------------
insert into "YXYUP"."TEST_SHRINK"("OWNER","OBJECT_NAME","SUBOBJECT_NAME","OBJECT
_ID","DATA_OBJECT_ID","OBJECT_TYPE","CREATED","LAST_DDL_TIME","TIMESTAMP","STATU
S","TEMPORARY","GENERATED","SECONDARY") values ('SYS','USER_QUEUE_PUBLISHERS',NU
LL,'4623',NULL,'VIEW',TO_DATE('20-JAN-07', 'DD-MON-RR'),TO_DATE('20-JAN-07', 'DD
-MON-RR'),'2007-01-20:04:25:26','VALID','N','N','N');
DELETE
delete from "YXYUP"."TEST_SHRINK" where "OWNER" = 'PUBLIC' and "OBJECT_NAME" = '
USER_QUEUE_PUBLISHERS' and "SUBOBJECT_NAME" IS NULL and "OBJECT_ID" = '4624' and
OPERATION
--------------------------------
SQL_REDO
--------------------------------------------------------------------------------
"DATA_OBJECT_ID" IS NULL and "OBJECT_TYPE" = 'SYNONYM' and "CREATED" = TO_DATE(
'20-JAN-07', 'DD-MON-RR') and "LAST_DDL_TIME" = TO_DATE('20-JAN-07', 'DD-MON-RR'
) and "TIMESTAMP" = '2007-01-20:04:25:26' and "STATUS" = 'VALID' and "TEMPORARY"
= 'N' and "GENERATED" = 'N' and "SECONDARY" = 'N' and ROWID = 'AAACiUAAEAAANLOA
Ar';
INSERT
insert into "YXYUP"."TEST_SHRINK"("OWNER","OBJECT_NAME","SUBOBJECT_NAME","OBJECT
_ID","DATA_OBJECT_ID","OBJECT_TYPE","CREATED","LAST_DDL_TIME","TIMESTAMP","STATU
OPERATION
--------------------------------
SQL_REDO
--------------------------------------------------------------------------------
S","TEMPORARY","GENERATED","SECONDARY") values ('PUBLIC','USER_QUEUE_PUBLISHERS'
,NULL,'4624',NULL,'SYNONYM',TO_DATE('20-JAN-07', 'DD-MON-RR'),TO_DATE('20-JAN-07
', 'DD-MON-RR'),'2007-01-20:04:25:26','VALID','N','N','N');
......................
可以看出shrink space 的整個過程都是在做delete和insert 操作,
感覺這個操作在生產DB不是逼不得已的時候,還是不用為好
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/7364032/viewspace-17473/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- ALTER TABLE MOVE和SHRINK SPACE區別
- shrink space的最佳實踐
- alter table move 和 alter table shrink space的區別
- Oracle 10g Shrink Table - Shrink Space 收縮空間Oracle 10g
- Oracle中shrink space命令詳解Oracle
- ALTER TABLE MOVE | SHRINK SPACE區別
- [Oracle] Shrink space & Table move比較Oracle
- Java程式碼編譯和執行的整個過程Java編譯
- alter table move 與shrink space的區別
- alter table move跟shrink space的區別
- oracle10g shrink space 降低HWMOracle
- alter table move跟shrink space的區別(轉)
- 模擬insert,update和delete造成阻塞的示例delete
- SHOW_SPACE儲存過程儲存過程
- 【Oracle】-【show_space和show_space_asm】-執行儲存過程報錯OracleASM儲存過程
- 用merge 語句代替 insert 和deletedelete
- 【深度好文】我在做前端構建過程中的思考前端
- 利用insert,update和delete注入獲取資料delete
- Oracle 11g alter table move與shrink spaceOracle
- oracle 10g__alter table shrink space compactOracle 10g
- 直接insert與儲存過程insert效能區別儲存過程
- 簡單上手SpringBean的整個裝配過程SpringBean
- PostgreSQL的insert語句執行過程分析SQL
- 在做一個support,今天看程式碼的過程中遇到個問題,望大家給點指點。
- sql server 帶有OUTPUT的INSERT,DELETE,UPDATESQLServerdelete
- 380. Insert Delete GetRandom O (1)deleterandom
- 34、VIEW可以insert,delete,update.Viewdelete
- Oracle IZ0-053 Q277(Table shrink space)Oracle
- Oracle中shrink space命令詳解[轉]--還示測試Oracle
- 【故障公告】1個儲存過程拖垮整個資料庫儲存過程資料庫
- 【實驗】【Tom】show_space儲存過程的使用演示儲存過程
- 你走過最長的路 ,就是機器學習過程中的彎路機器學習
- mysql 在delete、insert、update 時,page的變化MySqldelete
- MySQL之資料的insert-delete-update操作MySqldelete
- java-Mybatis XML 對映器(select,insert, update 和 delete)JavaMyBatisXMLdelete
- mysql innodb新建索引堵塞update ,insert,deleteMySql索引delete
- C++中過載new和delete的使用C++delete
- Oracle OCP 1Z0 053 Q96(Shrink Space Compact)Oracle