在 Oracle 10g 中创建表空间脚本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2102265/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Create Tablespace Script in Oracle 10g
提问by Srinivasan Thirunavukkarasu
I am using the below script for generating a DDL to create tablespaces in the database.
我正在使用以下脚本生成 DDL 以在数据库中创建表空间。
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 To Recreate Tablespaces"
from dba_data_files df, dba_tablespaces t
where df.tablespace_name=t.tablespace_name;
It works good. But when a tablespace contains two datafiles then also it creates seperate command with create tablespace. Simply it creates two create tablespace commands if a tablespace contains two datafiles. Please share your thoughts.
它运作良好。但是当一个表空间包含两个数据文件时,它也会使用 create tablespace 创建单独的命令。如果一个表空间包含两个数据文件,它会简单地创建两个 create tablespace 命令。请分享您的想法。
Cheers,
干杯,
Srinivasan Thirunavukkarasu.
Srinivasan Thirunavukkarasu。
回答by dpbradley
If you're just trying to reverse-engineer an existing tablespace to generate a script, why not just use DBMS_METADATA?
如果您只是想对现有表空间进行逆向工程以生成脚本,为什么不直接使用 DBMS_METADATA?
select dbms_metadata.get_ddl('TABLESPACE','yourTablespaceNameOfInterest')
from dual;
You can generate one of these statements for each tablespace in the database with a simple wrapper if you want them all.
如果需要,可以使用简单的包装器为数据库中的每个表空间生成这些语句之一。
回答by Babu R
SET LONG 1000000
select dbms_metadata.get_ddl('TABLESPACE','tablespace_name')||';' from dual;
回答by grokster
select
dbms_metadata.get_ddl('TABLESPACE',tablespace_name)
from
dba_tablespaces
;