-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenable_indexes_constraints.sql
48 lines (38 loc) · 1.93 KB
/
enable_indexes_constraints.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
--------------------------------------------------------
-- File created - Wednesday-June-19-2019
--------------------------------------------------------
--------------------------------------------------------
-- DDL for Procedure ENABLE_INDEXES_CONSTRAINTS
--------------------------------------------------------
set define off;
CREATE OR REPLACE NONEDITIONABLE PROCEDURE ENABLE_INDEXES_CONSTRAINTS(schema_name_in IN varchar2,table_name_in IN varchar2)
IS
BEGIN
for i in ( select owner,table_name, constraint_name
from all_constraints
where table_name = UPPER(table_name_in)
and owner = UPPER(schema_name_in) )
loop
dbms_output.put_line('alter table '|| i.owner ||'.'|| i.table_name ||' enable constraint '|| i.constraint_name);
execute immediate 'alter table '|| i.owner || '.' || i.table_name ||' enable constraint '|| i.constraint_name;
end loop;
declare create_idx_q varchar(200) := 'CREATE';
BEGIN
for i in ( select *
from dropped_indexes_bulk_load
where table_name = UPPER(table_name_in)
and owner = UPPER(schema_name_in))
loop
dbms_output.put_line('create index '|| i.owner || '.' || i.index_name);
IF i.uniqueness = 'UNIQUE'
THEN create_idx_q := create_idx_q ||' UNIQUE';
END IF;
create_idx_q := create_idx_q || ' INDEX ' || i.index_name || ' ON ' || i.table_name || '(' || i.column_name || ')';
dbms_output.put_line(create_idx_q);
execute immediate create_idx_q ;
dbms_output.put_line('Delete from dropped_indexes_bulk_load where OWNER = ' || '''' || i.owner || '''' || ' AND ' || 'TABLE_NAME = ' || '''' || i.TABLE_NAME || '''');
execute immediate 'Delete from dropped_indexes_bulk_load where OWNER = ' || '''' || i.owner || '''' || ' AND ' || 'TABLE_NAME = ' || '''' || i.TABLE_NAME || '''';
end loop;
END;
END;
/