scripting - Create Tablespace Script in Oracle 10g -


i using below script generating ddl create tablespaces in database.

select 'create tablespace ' || df.tablespace_name || chr(10)  || ' datafile ''' || df.file_name || ''' size ' || df.bytes   || decode(autoextensible,'n',null, chr(10) || ' autoextend on maxsize '   || maxbytes)   || chr(10)   || 'default storage ( initial ' || initial_extent   || decode (next_extent, null, null, ' next ' || next_extent )  || ' minextents ' || min_extents  || ' maxextents ' ||  decode(max_extents,'2147483645','unlimited',max_extents)   || ') ;' "script recreate tablespaces"  dba_data_files df, dba_tablespaces t  df.tablespace_name=t.tablespace_name; 

it works good. when tablespace contains 2 datafiles creates seperate command create tablespace. creates 2 create tablespace commands if tablespace contains 2 datafiles. please share thoughts.

cheers,

srinivasan thirunavukkarasu.

if you're trying reverse-engineer existing tablespace generate script, why not use dbms_metadata?

select dbms_metadata.get_ddl('tablespace','yourtablespacenameofinterest')  dual; 

you can generate 1 of these statements each tablespace in database simple wrapper if want them all.


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -