[轉]How to release space from database
How to release space from database
這篇文章比較詳細,包括回收到HWM,以及如何降低HWM後再繼續回收。
[@more@]How to release space from database
(Step 3-5 only applies to development/testing DB or in an offline production DB, because move table would destroy index.)
當然就是resize datafile 了,下面稍微寫了一下步驟
How to release space from database
(Step 3-5 only applies to development/testing DB or in an offline production DB, because move table would destroy index.)
1. Find which tablespace have much free space.
Select sum(bytes)/1024/1024 , tablespace_name from dba_free_space
Group by tablespace_name order by 1 desc
SUM(BYTES)/1024/1024 TABLESPACE_NAME
721.0625 USERS
327.25 UNDOTBS1
2. For the tablespace that has much free space, try to resize it to the highest blocks.
SELECT 'alter database datafile '||d.file_id ||' resize '||
NVL(ROUND(MAX(e.block_id+e.blocks -1)* t.block_size /1024/1024+1),11)||'M;'
FROM dba_extents e, dba_data_files d , dba_tablespaces t
WHERE d.tablespace_name = t. tablespace_name
AND d.file_id = e.file_id(+)
AND t. tablespace_name = :tbsname
AND e. tablespace_name(+) = :tbsname
GROUP BY d.file_id , t.block_size
SCRIPT
alter database datafile 5 resize 237M;
alter database datafile 6 resize 41M;
3. Check if there is still much free space. If not, continue to the next tablespace, Else, continue to the next step.
4. Find the free space of the tablespace.
SELECT file_id , block_id, block_id+blocks , blocks
FROM dba_free_space
WHERE TABLEspace_name = :tbsname
ORDER BY 1, 2 DESC
FILE_ID
First_block
Last_block
Total Block
5
30217
30337
120
5
28937
29833
896
5
28553
28681
128
5
28185
28297
112
5
28129
28169
40
5
28081
28121
40
5
13129
28041
14912
5
7601
13097
5496
5
2657
7585
4928
5
2585
2625
40
5
137
2569
2432
6
5105
5249
144
6
5081
5097
16
6
5001
5073
72
6
4745
4849
104
6
3625
4705
1080
6
97
3593
3496
5. For each file, try to move the segment down the big free chunk.
a. Move tables above the point
b. Rebuild affected indexes
c. Rebuild indexes above the point
a. Move tables above the point
Select distinct ‘alter table ‘||owner||’.’||segment_name||’ move ;’
From dba_extents
Where file_id = :file_id
And segment_type = ‘TABLE’
And tablespace_name = :tbs_name
And block_id > :block_id --(for file_id 6, should be 3593)
b. Rebuild affected indexes
Select ‘alter index ‘||owner||’.’||index_name||’ rebuild;’
From all_indexes
where status = ‘UNUSED’
c. Rebuild indexes above the point
Select distinct ‘alter table ‘||owner||’.’||segment_name||’ move ;’
From dba_extents
Where file_id = :file_id
And segment_type = ‘INDEX’
And tablespace_name = :tbs_name
And block_id > :block_id --(for file_id 6, should be 3593)
6. Continue step 2
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/271283/viewspace-1013009/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- [轉帖]Release Schedule of Current Database Releases (Doc ID 742060.1)Database
- How to debug release mode program in visual studio
- How to build your custom release bazel version?UI
- The database owner SID recorded in the master database differs from the database owner SID recorded in database 'DB_NAME'DatabaseAST
- ORA-16649: possible failover to another database prevents this database from beiAIDatabase
- how to move a MediaWiki wiki from one server to anotherServer
- How to prevent your jar packages from being decompiled?JARPackageCompile
- How To Copy Any Text To Clipboard From Terminal In UbuntuUbuntu
- cannot reclaim 52428800 bytes disk space from 4070572032 limitAIMIT
- 1 Oracle Database Release 20c New FeaturesOracleDatabase
- How to Collect Diagnostics for Database Hanging Issues (Doc ID 452358.1)Database
- Converting Oracle Database from Linux to Windows using RMANOracleDatabaseLinuxWindows
- Oracle database 升級(文件)to 10.2.0.4 from 10.2.0.1OracleDatabase
- show_space(轉)
- Oracle 19c Concepts(00):Changes in This Release for Oracle Database ConceptsOracleDatabase
- [20221222]How to Enable and Disable Database Options in oracle 11g.txtDatabaseOracle
- How to redirect to a specific web page after sign out from Entra IDWeb
- How To Replicate Data from Oracle to Postgres Using GoldenGate (Doc ID 1544137.1OracleGo
- Automatic Diagnostic Repository (ADR) in Oracle Database 11g Release 1 (ADRCI)OracleDatabase
- [20201110]How to get the Data Guard broker configuration from a SQL query.txtSQL
- Setup Standby Database on One PC(轉)Database
- Scheduler in Oracle Database 10g(轉)OracleDatabase
- Oracle 19c透過recover standby database from service修復GAP案例OracleDatabase
- 【文獻解讀】Generating Sentences from a Continuous Space,VAE產生連續空間變數變數
- SUPTOOL: BBED - 7.3.2+ Database Block Editor(轉)DatabaseBloC
- 聊聊dba_temp_free_space的allocated_space和free_space
- 轉載 個人用 How To Remove Docker Images, Containers, and VolumesREMDockerAI
- Hilbert Space
- 大資料CHENGDAYE中日期轉換FROM_大資料
- How to ssh
- 【轉載】使用 BAPI_BUPA_CREATE_FROM_DATA 建立BPAPI
- 【CV】三維空間的旋轉問題(Rotation in 3D space)3D
- Oracle Database Cloud - Database as a Service Quick StartOracleDatabaseCloudUI
- Error querying database. XXXXXXXXXXXXX, No database selected。ErrorDatabase
- Convert a Physical Standby Database into a Snapshot Standby DatabaseDatabase
- CSS white-spaceCSS
- D. Explorer Space
- How to find dependency
- ubuntu apt update 提示 The repository ‘http://xxx Release‘ does not have a Release fileUbuntuAPTHTTP