我使用以下脚本生成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;
效果很好。但是当表空间包含两个数据文件时,它还会使用create tablespace创建单独的命令。如果表空间包含两个数据文件,它只创建两个create tablespace命令。请分享您的想法。
干杯,
Srinivasan Thirunavukkarasu。
答案 0 :(得分:5)
如果您只是尝试对现有表空间进行反向工程以生成脚本,为什么不使用DBMS_METADATA?
select dbms_metadata.get_ddl('TABLESPACE','yourTablespaceNameOfInterest')
from dual;
如果需要,可以使用简单的包装器为数据库中的每个表空间生成其中一个语句。
答案 1 :(得分:0)
<!-- Load the video iframe. Be sure to not forget to enable the api (api=1) -->
<iframe src="https://player.vimeo.com/video/87982573?api=1" width="640" height="360" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
<!-- When clicking this text the video will start -->
<p id='start'>click to start</p>
<!-- Including jQuery -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!-- Including Vimeo player javascript API -->
<script src="https://player.vimeo.com/api/player.js"></script>
<script>
var iframe = document.querySelector('iframe');
var player = new Vimeo.Player(iframe);
// Execute the `play` method of the API when something with id start is clicked
$('#start').click( function() {
player.play();
});
</script>
答案 2 :(得分:-1)
select
dbms_metadata.get_ddl('TABLESPACE',tablespace_name)
from
dba_tablespaces
;