-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathar_move_tablespace.sql
61 lines (48 loc) · 1.58 KB
/
ar_move_tablespace.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
CREATE OR REPLACE procedure ar_move_tablespace (dest_tablespace varchar2)
is
db_target user_tables.table_name%type;
cursor nobuonetabelle
is
select distinct table_name from user_tab_columns where data_type in ('LONG');
cursor nobuoneindici
is
select distinct index_name from user_indexes where index_type in ('LOB');
cursor stat
is
select 'alter table ' || table_name || ' move tablespace '|| dest_tablespace STATEMENT
from
user_tables
where tablespace_name != dest_tablespace
and table_name not in (select distinct table_name from user_tab_columns where data_type in ('LONG'));
cursor rebindx
is
select 'alter index ' || index_name || ' rebuild tablespace '|| dest_tablespace STATEMENT
from
user_indexes
where tablespace_name != dest_tablespace
and index_name not in (select distinct index_name from user_indexes where index_type in ('LOB'));
begin
for cur_row in stat loop
begin
execute immediate cur_row.STATEMENT;
null;
exception when others then
raise_application_error (-20101, sqlerrm || '*** Errore: Spostamento Tablespace : ' ||cur_row.STATEMENT);
end;
end loop;
for cur_indx in rebindx loop
begin
execute immediate cur_indx.STATEMENT;
--null;
exception when others then
raise_application_error (-20101, sqlerrm || '*** Errore: Spostamento Indice : ' ||cur_indx.STATEMENT);
end;
end loop;
for nogoodtable in nobuonetabelle loop
dbms_output.put_line ('Non riesco a spostare la tabella.:'|| nogoodtable.table_name );
end loop;
for nogoodindex in nobuoneindici loop
dbms_output.put_line ('Non riesco a spostare l''indice.:'|| nogoodindex.index_name );
end loop;
end;
/