forked from abdulirfan3/Oracle_SQL_Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
comp_top50tables_sap_exc_list.sql
170 lines (165 loc) · 4.5 KB
/
comp_top50tables_sap_exc_list.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
set timing on
select * from
(
select
substr(segment_name,1,30) "Name",
round(sum(bytes)/1024/1024/1024) "Size (gb)",a.initial_extent,
count(*) "Partitions"
from dba_segments a,dba_tables b
where segment_type like 'TAB%' and
a.owner='SAPSR3'
and
segment_name not like 'ARFC%' and
segment_name not like 'TRFC%' and
segment_name not like 'QRFC%' and
segment_name not in ('VBHDR','VBDATA','VBMOD','VBERROR','REPOSRC','REPOLOAD','NRIV') and
a.segment_name=b.table_name and
compression!='ENABLED'
and not exists
(select 'x' from dba_tab_cols c
where c.owner=a.owner and c.table_name=a.segment_name and c.data_type='BLOB')
group by substr(segment_name,1,30),a.initial_extent
order by 2 desc
)
where rownum<51
/
select sum("Size (gb)") "sum of top50"
from
(
select * from
(
select
substr(segment_name,1,30) "Name",
round(sum(bytes)/1024/1024/1024) "Size (gb)",
count(*) "Partitions"
from dba_segments a,dba_tables b
where segment_type like 'TAB%' and
a.owner='SAPSR3'
and
segment_name not like 'ARFC%' and
segment_name not like 'TRFC%' and
segment_name not like 'QRFC%' and
segment_name not in ('VBHDR','VBDATA','VBMOD','VBERROR','REPOSRC','REPOLOAD','NRIV') and
a.segment_name=b.table_name and
compression!='ENABLED'
and not exists
(select 'x' from dba_tab_cols c
where c.owner=a.owner and c.table_name=a.segment_name and c.data_type='BLOB')
group by substr(segment_name,1,30)
order by 2 desc
)
where rownum<51
)
/
select sum("Size (gb)") "sum of compressable tables"
from
(
select * from
(
select
substr(segment_name,1,30) "Name",
round(sum(bytes)/1024/1024/1024) "Size (gb)",
count(*) "Partitions"
from dba_segments a,dba_tables b
where segment_type like 'TAB%' and
a.owner='SAPSR3'
and
segment_name not like 'ARFC%' and
segment_name not like 'TRFC%' and
segment_name not like 'QRFC%' and
segment_name not in ('VBHDR','VBDATA','VBMOD','VBERROR','REPOSRC','REPOLOAD','NRIV') and
a.segment_name=b.table_name and
compression!='ENABLED'
and not exists
(select 'x' from dba_tab_cols c
where c.owner=a.owner and c.table_name=a.segment_name and c.data_type='BLOB')
group by substr(segment_name,1,30)
order by 2 desc
)
)
/
prompt
prompt
prompt ###################################################
prompt VERSION 2
prompt ###################################################
prompt
set timing on
select * from
(
select
substr(segment_name,1,30) "Name",
round(sum(bytes)/1024/1024/1024) "Size (gb)",a.initial_extent,
count(*) "Partitions"
from dba_segments a,dba_tables b
where segment_type like 'TAB%' and
a.owner='SAPSR3'
and
segment_name not like 'ARFC%' and
segment_name not like 'TRFC%' and
segment_name not like 'QRFC%' and
segment_name not in ('VBHDR','VBDATA','VBMOD','VBERROR','REPOSRC','REPOLOAD','NRIV') and
a.segment_name=b.table_name and
(compression ='DISABLED' or compression is null)
and not exists
(select 'x' from dba_tab_cols c
where c.owner=a.owner and c.table_name=a.segment_name and c.data_type='BLOB')
group by substr(segment_name,1,30),a.initial_extent
order by 2 desc
)
where rownum<51
/
select sum("Size (gb)") "sum of top50"
from
(
select * from
(
select
substr(segment_name,1,30) "Name",
round(sum(bytes)/1024/1024/1024) "Size (gb)",
count(*) "Partitions"
from dba_segments a,dba_tables b
where segment_type like 'TAB%' and
a.owner='SAPSR3'
and
segment_name not like 'ARFC%' and
segment_name not like 'TRFC%' and
segment_name not like 'QRFC%' and
segment_name not in ('VBHDR','VBDATA','VBMOD','VBERROR','REPOSRC','REPOLOAD','NRIV') and
a.segment_name=b.table_name and
(compression ='DISABLED' or compression is null)
and not exists
(select 'x' from dba_tab_cols c
where c.owner=a.owner and c.table_name=a.segment_name and c.data_type='BLOB')
group by substr(segment_name,1,30)
order by 2 desc
)
where rownum<51
)
/
select sum("Size (gb)") "sum of compressable tables"
from
(
select
substr(segment_name,1,30) "Name",
round(sum(bytes)/1024/1024/1024) "Size (gb)",
count(*) "Partitions"
from dba_segments a
,dba_tables b
where segment_type like 'TAB%' and
a.owner='SAPSR3'
and
segment_name not like 'ARFC%' and
segment_name not like 'TRFC%' and
segment_name not like 'QRFC%' and
segment_name not in ('VBHDR','VBDATA','VBMOD','VBERROR','REPOSRC','REPOLOAD','NRIV') and
a.segment_name=b.table_name
and
(compression ='DISABLED' or compression is null)
and
not exists
(select 'x' from dba_tab_cols c
where c.owner=a.owner and c.table_name=a.segment_name and c.data_type='BLOB')
group by substr(segment_name,1,30)
)
/