Skip to content

Commit e1ad429

Browse files
committed
added oracle_table_segments_for_schema.sql
1 parent 6ce19ef commit e1ad429

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

oracle_table_segments_for_schema.sql

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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 Tables' Segments Size in a given Tablespace
17+
--
18+
-- Tested on Oracle 19c
19+
20+
SELECT
21+
segment_name,
22+
segment_type,
23+
tablespace_name,
24+
bytes/1024/1024/1024 AS size_gb,
25+
blocks
26+
FROM
27+
dba_segments
28+
WHERE
29+
owner = 'USERS' -- XXX: Edit this
30+
AND
31+
segment_type = 'TABLE'
32+
AND
33+
blocks > 8
34+
-- to look at only specific tables
35+
-- AND
36+
--segment_name IN
37+
--('MY_TABLE_1',
38+
-- 'MY_TABLE_2',
39+
-- 'MY_TABLE_3',
40+
-- 'MY_TABLE_4')
41+
ORDER BY
42+
size_gb DESC;

0 commit comments

Comments
 (0)