/
drop_xviews.sql
56 lines (44 loc) · 1.41 KB
/
drop_xviews.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
-- Copyright 2018 Tanel Poder. All rights reserved. More info at http://tanelpoder.com
-- Licensed under the Apache License, Version 2.0. See LICENSE.txt for terms & conditions.
--------------------------------------------------------------------------------
--
-- Name: drop_xviews.sql
-- Purpose: Drop custom views, grants and synonyms for X$ fixed tables
-- Usage: Run from sqlplus as SYS: @drop_xviews.sql
--
--
-- Author: (c) Tanel Poder http://www.tanelpoder.com
--
-- Other: Note that this script only generatesd drop commands for manual
-- execution. Make sure that you don't drop any X$ tables required
-- by other software like StatsPack and monitoring tools
--
--------------------------------------------------------------------------------
@saveset
set pagesize 0
set linesize 200
set trimspool on
set feedback off
Prompt Generating drop script...
spool drop_xviews.tmp
set termout off
select 'drop view '||object_name||';'
from (
select object_name
from dba_objects
where owner = 'SYS'
and object_name like 'X\_$%' escape '\'
);
select 'drop public synonym '||synonym_name||';'
from (
select synonym_name
from dba_synonyms
where owner = 'PUBLIC'
and synonym_name like 'X$%'
);
spool off
set termout on
Prompt Done generating drop script.
Prompt Now review and manually execute the file drop_xviews.tmp using @drop_xviews.tmp
Prompt
@loadset