Skip to content

Commit 5cb9209

Browse files
committed
added oracle_table_shrink_candidates.sql
1 parent fbac254 commit 5cb9209

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

oracle_table_shrink_candidates.sql

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
--
2+
-- Author: Hari Sekhon
3+
-- Date: 2024-10-11 03:24:48 +0300 (Fri, 11 Oct 2024)
4+
--
5+
-- vim:ts=4:sts=4:sw=4:et:filetype=sql
6+
--
7+
-- https///github.com/HariSekhon/SQL-scripts
8+
--
9+
-- License: see accompanying Hari Sekhon LICENSE file
10+
--
11+
-- If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
12+
--
13+
-- https://www.linkedin.com/in/HariSekhon
14+
--
15+
16+
-- Oracle - Show Table Candidates to Move / Shrink in a given Tablespace
17+
--
18+
-- where the tables are over 20% utilized
19+
--
20+
-- Tested on Oracle 19c
21+
22+
SELECT
23+
segment_name,
24+
segment_type,
25+
ROUND(SUM(bytes)/1024/1024/1024, 2) AS size_gb
26+
FROM
27+
dba_segments
28+
WHERE
29+
tablespace_name = 'USERS' -- XXX: Edit
30+
GROUP BY
31+
segment_name,
32+
segment_type
33+
HAVING
34+
SUM(bytes)/1024/1024/1024 > 1
35+
ORDER BY
36+
size_gb DESC;

0 commit comments

Comments
 (0)