-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdrop.PyTL_Interfaces_.sql
More file actions
50 lines (45 loc) · 1.96 KB
/
Copy pathdrop.PyTL_Interfaces_.sql
File metadata and controls
50 lines (45 loc) · 1.96 KB
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
/*
pythonist552 <at> gmail <dot> com
220904.1 = universal script for tables/packages dropping
*/
set linesize 2000
set serveroutput on
set verify off
declare
type LIST_OF_STR is table of varchar2(256);
V_TABLE_NAMES_TO_DROP LIST_OF_STR := LIST_OF_STR(
'PyTL_Sequences'
,'PyTL_Interfaces_Records'
,'PyTL_Interfaces_Batches'
);
V_PACKAGE_NAMES_TO_DROP LIST_OF_STR := LIST_OF_STR(
'PyTL_Interfaces_Utils'
);
begin
for i in 1 .. V_TABLE_NAMES_TO_DROP.count loop
dbms_output.put_line('*** Try to find table ' || V_TABLE_NAMES_TO_DROP(i) || ' and linked sequences.');
for SEQUENCE_TO_DROP in (
select * from ALL_SEQUENCES where upper(SEQUENCE_NAME) like upper(V_TABLE_NAMES_TO_DROP(i) || '__%')
) loop
dbms_output.put_line('** Sequence is found, so drop sequence ' || SEQUENCE_TO_DROP.SEQUENCE_NAME);
execute immediate 'drop sequence ' || SEQUENCE_TO_DROP.SEQUENCE_NAME;
end loop;
for TABLE_TO_DROP in (
select * from USER_TABLES where upper(TABLE_NAME) like upper(V_TABLE_NAMES_TO_DROP(i))
) loop
dbms_output.put_line('** Table is found, so drop table ' || TABLE_TO_DROP.TABLE_NAME || ' and linked constraints, indexes, triggers, ');
execute immediate 'drop table ' || TABLE_TO_DROP.TABLE_NAME || ' cascade constraints';
end loop;
end loop;
for i in 1 .. V_PACKAGE_NAMES_TO_DROP.count loop
dbms_output.put_line('*** Try to find package ' || V_PACKAGE_NAMES_TO_DROP(i));
for PACKAGE_TO_DROP in (
select * from ALL_OBJECTS where OBJECT_TYPE = 'PACKAGE' and upper(OBJECT_NAME) like upper(V_PACKAGE_NAMES_TO_DROP(i))
) loop
dbms_output.put_line('** Package is found, so drop package ' || PACKAGE_TO_DROP.OBJECT_NAME);
execute immediate 'drop package ' || PACKAGE_TO_DROP.OBJECT_NAME;
end loop;
end loop;
end;
/
exit;