SELECT CASE WHEN LAG(TABLESPACE_NAME) OVER (ORDER BY RN)= TABLESPACE_NAME
THEN 'ALTER TABLESPACE '||TABLESPACE_NAME||' ADD DATAFILE '''||FILE_NAME||''' SIZE '||SIZEMB||'M '||
CASE WHEN LEAD(TABLESPACE_NAME) OVER (ORDER BY RN) = TABLESPACE_NAME OR TABLESPACE_NAME LIKE '%UNDO%'
THEN 'AUTOEXTEND OFF;'
ELSE 'AUTOEXTEND ON;'
END
ELSE 'CREATE TABLESPACE '||TABLESPACE_NAME||' DATAFILE '''||FILE_NAME||''' SIZE '|| SIZEMB||'M '||
CASE WHEN LEAD(TABLESPACE_NAME) OVER (ORDER BY RN) = TABLESPACE_NAME OR TABLESPACE_NAME LIKE '%UNDO%'
THEN 'AUTOEXTEND OFF;'
ELSE 'AUTOEXTEND ON;'
END
END
FROM
(
SELECT ROW_NUMBER() OVER (ORDER BY A.TABLESPACE_NAME,B.FILE_ID) RN,A.TABLESPACE_NAME,B.FILE_NAME,B.BYTES/1024/1024 SIZEMB
FROM DBA_TABLESPACES A,DBA_DATA_FILES B
WHERE A.TABLESPACE_NAME=B.TABLESPACE_NAME
)
THEN 'ALTER TABLESPACE '||TABLESPACE_NAME||' ADD DATAFILE '''||FILE_NAME||''' SIZE '||SIZEMB||'M '||
CASE WHEN LEAD(TABLESPACE_NAME) OVER (ORDER BY RN) = TABLESPACE_NAME OR TABLESPACE_NAME LIKE '%UNDO%'
THEN 'AUTOEXTEND OFF;'
ELSE 'AUTOEXTEND ON;'
END
ELSE 'CREATE TABLESPACE '||TABLESPACE_NAME||' DATAFILE '''||FILE_NAME||''' SIZE '|| SIZEMB||'M '||
CASE WHEN LEAD(TABLESPACE_NAME) OVER (ORDER BY RN) = TABLESPACE_NAME OR TABLESPACE_NAME LIKE '%UNDO%'
THEN 'AUTOEXTEND OFF;'
ELSE 'AUTOEXTEND ON;'
END
END
FROM
(
SELECT ROW_NUMBER() OVER (ORDER BY A.TABLESPACE_NAME,B.FILE_ID) RN,A.TABLESPACE_NAME,B.FILE_NAME,B.BYTES/1024/1024 SIZEMB
FROM DBA_TABLESPACES A,DBA_DATA_FILES B
WHERE A.TABLESPACE_NAME=B.TABLESPACE_NAME
)
※ UNDO는 AUTOEXTEND OFF 설정
※ 템프파일은 따로 생성 및 크기 조절할것.
'Oracle > admin' 카테고리의 다른 글
RAC 클러스터 환경을 안정화하기 위한 주요 11가지 방안 (문서 ID 1575936.1) (0) | 2016.12.13 |
---|---|
Enabling and Disabling Maintenance Tasks for all Maintenance Windows (0) | 2016.11.17 |
2pc_pending 처리 (0) | 2016.11.07 |
Oracle Streams 상태조회 (0) | 2016.11.02 |
Oracle Support 한국어 문서 목록 (0) | 2016.09.09 |