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
- 利用insert,update和delete注入獲取資料delete
- [20190918]shrink space與ORA-08102錯誤.txt
- sql server 帶有OUTPUT的INSERT,DELETE,UPDATESQLServerdelete
- 380. Insert Delete GetRandom O (1)deleterandom
- java-Mybatis XML 對映器(select,insert, update 和 delete)JavaMyBatisXMLdelete
- PostgreSQL的insert語句執行過程分析SQL
- 簡單上手SpringBean的整個裝配過程SpringBean
- mysql 在delete、insert、update 時,page的變化MySqldelete
- 【深度好文】我在做前端構建過程中的思考前端
- [LeetCode] 380. Insert Delete GetRandom O(1)LeetCodedeleterandom
- SQLite語句(二):INSERT DELETE UPDATE SELECTSQLitedelete
- DBeaver如何生成select,update,delete,insert語句delete
- SQL Server的Merge —— 一步實現 insert,update,deleteSQLServerdelete
- Sqlserver、oracle中Merge的使用方法,一個merge語句搞定多個Insert,Update,Delete操作SQLServerOracledelete
- KunlunDB功能之insert/update/delete...returning語句delete
- 【故障公告】1個儲存過程拖垮整個資料庫儲存過程資料庫
- 輕量ORM-SqlRepoEx (四)INSERT、UPDATE、DELETE 語句ORMSQLdelete
- 數字化轉型的過程就是價值創造、創新和增長的過程
- 成長,就是不斷向自己妥協的過程
- mybatis-spring原始碼分析-一次insert過程MyBatisSpring原始碼
- FLASK藍本使用初體驗,個人對整個構建過程的理解Flask
- 聊聊dba_temp_free_space的allocated_space和free_space
- insert all和insert first語句的用法
- 你走過最長的路 ,就是機器學習過程中的彎路機器學習
- MySQL死鎖案例分析一(先delete,再insert,導致死鎖)MySqldelete
- MyBatis(五) insert、update、delete 、主鍵回填、返回matched行數和affected行數、引數配置#{},${}MyBatisdelete
- 如何用同一套賬號接入整個研發過程?
- MySQL全文索引原始碼剖析之Insert語句執行過程MySql索引原始碼
- PostgreSQL 原始碼解讀(15)- Insert語句(執行過程跟蹤)SQL原始碼
- 一次死鎖導致CPU異常飄高的整個故障排查過程
- HashMap中紅黑樹插入節點的調整過程HashMap
- Oracle中的insert/insert all/insert firstOracle
- Oracle move和shrink釋放高水位空間Oracle
- 3069 求n個整數的和
- 微服務的架構演進過程和多個解決方案微服務架構
- 《Space Engine》:一個人的孤獨宇宙
- vector::shrink_to_fit()
- CSS flex-shrinkCSSFlex