Update get_tablespaces_ddl.sql

This commit is contained in:
Yacine31
2021-11-26 05:40:28 +01:00
parent 0d1e3e500b
commit f445e2a6e8

View File

@@ -11,7 +11,6 @@
set head off pages 0 feedback off lines 200 set head off pages 0 feedback off lines 200
select '------- HOSTNAME : '||host_name||', DB_NAME : '||name||', VERSION : '||version || ' -------' from v$database,v$instance; select '------- HOSTNAME : '||host_name||', DB_NAME : '||name||', VERSION : '||version || ' -------' from v$database,v$instance;
select '------- Datafiles -------' from dual; select '------- Datafiles -------' from dual;
SELECT 'CREATE ' SELECT 'CREATE '
@@ -28,14 +27,7 @@ SELECT 'CREATE '
df.autoextensible, df.autoextensible,
'YES', 'YES',
' AUTOEXTEND ON NEXT ' || ceil(df.increment_by*ts.block_size/1024/1024) || 'M MAXSIZE ' ' AUTOEXTEND ON NEXT ' || ceil(df.increment_by*ts.block_size/1024/1024) || 'M MAXSIZE '
|| TO_CHAR (FLOOR (maxbytes / POWER (1024, 2))) || 'M'), || FLOOR (maxbytes / POWER (1024, 2)) || 'M'),
-- || CASE
-- WHEN maxbytes < POWER (1024, 2)
-- THEN
-- TO_CHAR (maxbytes)
-- ELSE
-- TO_CHAR (FLOOR (maxbytes / POWER (1024, 2))) || 'M'
-- END),
',' || CHR (13) || CHR (10)) ',' || CHR (13) || CHR (10))
WITHIN GROUP (ORDER BY df.file_id, df.file_name) WITHIN GROUP (ORDER BY df.file_id, df.file_name)
|| ';' || ';'
@@ -48,27 +40,26 @@ SELECT 'CREATE '
and ts.tablespace_name not like '%UNDO%' and ts.tablespace_name not like '%UNDO%'
and e.file_id (+) = df.file_id and e.file_id (+) = df.file_id
and ts.tablespace_name = df.tablespace_name and ts.tablespace_name = df.tablespace_name
GROUP BY ts.tablespace_name, GROUP BY ts.tablespace_name,
ts.bigfile, ts.bigfile,
ts.block_size ts.block_size
ORDER BY ts.tablespace_name; ORDER BY ts.tablespace_name;
select '------- Tempfiles -------' from dual; select '------- Tempfiles -------' from dual;
SELECT 'CREATE TEMPORARY TABLESPACE "' || ts.tablespace_name || '" TEMPFILE ' || CHR (13) || CHR (10) SELECT 'CREATE TEMPORARY TABLESPACE "' || ts.tablespace_name || '" TEMPFILE ' || CHR (13) || CHR (10)
|| LISTAGG(decode(p.value, NULL, ' ''' || df.file_name || '''') || ' SIZE ' || LISTAGG(decode(p.value, NULL, ' ''' || df.file_name || '''') || ' SIZE '
-- || decode(floor(e.used_bytes/1024/1024),0,10,floor(e.used_bytes/1024/1024)) || 'M ' -- si taille nulle, on retourne 10M
|| CASE || CASE
-- si la taille est nulle ou < 1M on retourne 10M -- si la taille est nulle ou < 1M on retourne 1M
WHEN e.used_bytes is NULL or e.used_bytes < (1024*1024) WHEN e.used_bytes is NULL or e.used_bytes < (1024*1024)
THEN '10M' THEN '1M'
ELSE to_char(floor(e.used_bytes/(1024*1024))) || 'M' ELSE to_char(floor(e.used_bytes/(1024*1024))) || 'M'
END END
|| DECODE ( || DECODE (
df.autoextensible, df.autoextensible,
'YES', ' AUTOEXTEND ON NEXT ' || ceil(df.increment_by*ts.block_size/1024/1024) || 'M MAXSIZE ' 'YES',
|| FLOOR (maxbytes / POWER (1024, 2)) || 'M' ' AUTOEXTEND ON NEXT ' || ceil(df.increment_by*ts.block_size/1024/1024) || 'M MAXSIZE '
), || FLOOR (maxbytes / POWER (1024, 2)) || 'M'),
',' || CHR (13) || CHR (10)) ',' || CHR (13) || CHR (10))
WITHIN GROUP (ORDER BY df.file_id, df.file_name) WITHIN GROUP (ORDER BY df.file_id, df.file_name)
|| ';' || ';'
@@ -79,10 +70,10 @@ SELECT 'CREATE TEMPORARY TABLESPACE "' || ts.tablespace_name || '" TEMPFILE '
(select VALUE from v$parameter where name='db_create_file_dest') p (select VALUE from v$parameter where name='db_create_file_dest') p
WHERE e.file_id (+) = df.file_id WHERE e.file_id (+) = df.file_id
and ts.tablespace_name = df.tablespace_name and ts.tablespace_name = df.tablespace_name
GROUP BY ts.tablespace_name, GROUP BY ts.tablespace_name,
ts.bigfile, ts.bigfile,
ts.block_size ts.block_size
ORDER BY ts.tablespace_name; ORDER BY ts.tablespace_name;
exit exit