Sunteți pe pagina 1din 4

cancellare molte righe con commit intermedi

DELETE FROM myfata$$ WHERE rownum < 100000;


commit;
DELETE FROM myfata$$ WHERE rownum < 100000;
commit;
etc..

___________ INFO SPAZIO ______________________________________

SELECT owner, segment_name, MAX (block_id), segment_type,


SUM (BYTES) / 1024 / 1024 mb
FROM dba_extents
WHERE file_id = 13
GROUP BY owner, segment_name, segment_type
ORDER BY 3 DESC

select distinct s.tablespace_name from dba_segments s,dba_objects o


where segment_name=object_name
and s.owner=o.owner
and s.tablespace_name like '%name%'

select sum(bytes)/1024/1024/1024 from dba_segments

select tablespace_name, sum(bytes)/1024/1024 from dba_free_space


where tablespace_name like '%name%'
group by tablespace_name

select tablespace_name,
segment_name,owner, sum(bytes)/1024/1024
from dba_segments
where segment_name like '%LOG%'
group by tablespace_name,segment_name,owner
order by 4 desc

select sum(bytes)/1024/1024/1024 from dba_data_files

______________________________________________________________

_____________ CREATE TBS _____________________________________

CREATE TABLESPACE IDX_ORAname1N DATAFILE


'/database/SIUC/IDX/idx_name_01n.dbf' SIZE 128M AUTOEXTEND ON NEXT 128M MAXSIZE
10240M,
'/database/SIUC/IDX/idx_name_11n.dbf' SIZE 128M AUTOEXTEND ON NEXT 128M MAXSIZE
10240M,
'/database/SIUC/IDX/idx_name_02n.dbf' SIZE 128M AUTOEXTEND ON NEXT 128M MAXSIZE
10240M,
'/database/SIUC/IDX/idx_name_03n.dbf' SIZE 128M AUTOEXTEND ON NEXT 128M MAXSIZE
10240M,
'/database/SIUC/IDX/idx_name_04n.dbf' SIZE 128M AUTOEXTEND ON NEXT 128M MAXSIZE
10240M
LOGGING
ONLINE
PERMANENT
EXTENT MANAGEMENT LOCAL AUTOALLOCATE
BLOCKSIZE 16K
SEGMENT SPACE MANAGEMENT MANUAL;

_____________ INFO IN GENERALE ___________________________________

-- oggetti in tablespace "sbagliate"


select
distinct l.owner,l.object_name,l.object_type,s.segment_type,s.tablespace_name
from dba_segments s,dba_objects l
where s.segment_name=l.object_name
and s.owner=l.owner
and s.owner not like '%SYS%'
and s.tablespace_name not like '%'||s.owner||'%'

-- tabelle con LONG che non si possono spostare


select
distinct l.owner,l.table_name,s.tablespace_name
from dba_segments s,dba_tables l
where s.segment_name=l.table_name
and s.owner=l.owner
and s.owner not like '%SYS%'
and s.tablespace_name not like '%'||s.owner||'%'
and l.owner||l.table_name in (
select distinct owner||table_name from dba_tab_columns
where data_type like '%LONG%'
and owner not like '%SYS%')
order by 1,2

--- bytes da spostare


select
sum(bytes)/1024/1024
from dba_segments s,dba_objects l
where s.segment_name=l.object_name
and s.owner=l.owner
and s.owner not like '%SYS%'
and s.tablespace_name not like '%'||s.owner||'%'

--- dati da spostare


select
sum(bytes)/1024/1024
from dba_segments s,dba_tables l
where s.segment_name=l.table_name
and s.owner=l.owner
and s.owner not like '%SYS%'
and s.tablespace_name not like '%'||s.owner||'%'
_____________ MOVE TABLE ___________________________________

select distinct 'ALTER TABLE '||o.owner||'.'||o.table_name||' MOVE TABLESPACE


TBS_NAMEN;'
from dba_tables o
where
o.tablespace_name = 'TBS_NAME'

_____________ MOVE TABLE PARTITION _________________________

select distinct 'ALTER TABLE '||table_owner||'.'||table_name||' MOVE PARTITION '||


partition_name||
' TABLESPACE TBS_NAMEN;'
from dba_tab_partitions
where tablespace_name = 'TBS_NAME'

_____________ MOVE INDEX _____________________________________

select distinct 'ALTER INDEX '||owner||'.'||index_name||' REBUILD TABLESPACE


TBS_NAMEN;'
from dba_indexes
where tablespace_name = 'TBS_NAME'

_______________ MOVE LOB ____________________________________

select distinct
'ALTER TABLE '||l.owner||'.'||l.table_name||' MOVE LOB ('||l.column_name||') store
as (tablespace TBS_NAMEN);'
from dba_segments s,dba_lobs l
where s.segment_name=l.segment_name
and s.owner=l.owner
and s.tablespace_name = 'TBS_NAME'

__________________ INDEX REBUILD ____________________________

select ' alter index '||owner||'.'||index_name||' rebuild;'


from dba_indexes
where status='UNUSABLE'

_________ RESIZE TBS

select '
alter database datafile '''||file_name||''' resize 768M;
alter database datafile '''||file_name||''' autoextend on next 128M maxsize
10240M;'
from dba_data_files
where tablespace_name ='TBS_NAME'
-- -- -- -- drop tablespace TBS_NAME INCLUDING CONTENTS AND DATAFILES

S-ar putea să vă placă și