WITH DATA AS (
SELECT USER owner, segment_name, segment_type, SEGMENT_SUBTYPE,
SUM(bytes)/1024/1024/1024
FROM user_segments s
GROUP BY segment_name, segment_type, SEGMENT_SUBTYPE
ORDER BY SUM(bytes) DESC
)
SELECT
DATA.*,
CASE segment_type
WHEN 'LOBSEGMENT' THEN
'ALTER TABLE ' || LOWER(l.owner || '.' || l.table_name) || ' MOVE LOB(' || l.column_name || ') STORE AS (TABLESPACE users) ONLINE PARALLEL 16;'
WHEN 'LOB PARTITION' THEN
'ALTER TABLE ' || LOWER (p.table_owner || '.' || p.table_name ) || ' MOVE PARTITION ' || p.partition_name
|| ' LOB ( ' || LOWER ( p.column_name ) || ') STORE AS ( TABLESPACE users ) UPDATE INDEXES ONLINE PARALLEL 16;'
WHEN 'INDEX' THEN
'ALTER INDEX ' || LOWER(i.owner || '.' || i.index_name) || ' REBUILD /*ONLINE*/ PARALLEL 16;' || CHR(10) ||
'ALTER INDEX ' || LOWER(i.owner || '.' || i.index_name) || ' NOPARALLEL;'
WHEN 'TABLE' THEN
'ALTER TABLE ' || LOWER(l.owner || '.' || l.table_name) || ' MOVE ONLINE PARALLEL 16;'
END cmd
FROM DATA,
all_lobs l,
all_lob_partitions p,
all_indexes i
WHERE DATA.owner = l.owner(+)
AND data.segment_name = l.SEGMENT_NAME(+)
AND data.segment_name = p.lob_name(+)
AND data.owner = i.OWNER(+)
AND data.segment_name = i.index_name(+);
2024-07-25
Database move objects
Подписаться на:
Сообщения (Atom)