48 lines
1.8 KiB
SQL
48 lines
1.8 KiB
SQL
select 'alter table ' || do.owner || '.' || do.object_name ||
|
|
' move tablespace TARGET_TS;' as cmd_to_invoke
|
|
from dba_objects do, dba_segments ds, dba_tables dt
|
|
where do.owner=ds.owner and do.owner=dt.owner
|
|
and do.object_name = ds.segment_name and do.object_name=dt.table_name
|
|
and dt.iot_name is null and do.object_type='TABLE'
|
|
and ds.tablespace_name = 'DMSPACE';
|
|
|
|
select distinct 'alter table ' || dt.table_owner || '.' || dt.table_name ||
|
|
' move partition ' || dt.partition_name ||
|
|
' tablespace DMSPACE_tmp' || ';' as cmd_to_invoke
|
|
from
|
|
dba_tab_partitions dt
|
|
where dt.tablespace_name='DMSPACE'
|
|
order by 1;
|
|
|
|
spool Z:\oracle\scripts\index.sql
|
|
select 'alter table ' || owner || '.' || table_name || ' move tablespace DMSPACE_tmp;'
|
|
from dba_indexes
|
|
where tablespace_name='DMSPACE';
|
|
spool off
|
|
|
|
set linesize 400 pages 600 trimspool on numwidth 14
|
|
spool Z:\oracle\scripts\index_2.sql
|
|
select 'alter index ' || do.owner || '.' || do.object_name || ' rebuild tablespace DMSPACE_tmp;' as cmd
|
|
from dba_objects do, dba_segments ds, dba_indexes di
|
|
where ds.tablespace_name='DMSPACE'
|
|
and do.owner=ds.owner and do.owner=di.owner
|
|
and do.object_type = 'INDEX'
|
|
and di.index_type in('NORMAL', 'FUNCTION-BASED NORMAL')
|
|
and do.object_name = ds.segment_name and do.object_name = di.index_name ;
|
|
|
|
|
|
|
|
select distinct 'alter table ' || dtc.owner || '.' || dtc.table_name ||
|
|
' move lob(' || column_name || ')' ||
|
|
' store as (tablespace DMSPACE);' as cmd_to_invoke
|
|
from dba_tab_columns dtc,
|
|
dba_tables dt,
|
|
dba_indexes di
|
|
where dt.owner=dtc.owner and dt.owner=di.owner
|
|
and dt.table_name=di.table_name and dt.table_name=dtc.table_name
|
|
and dtc.data_type like '%LOB%'
|
|
and di.index_name in
|
|
(select segment_name from dba_segments inner
|
|
where inner.owner=dt.owner and tablespace_name='DMSPACE_TMP')
|
|
|