我尝试使用SQLPLUS中的SPOOL命令为数据库中的对象生成所有DDL:
SET trimspool ON
SET wrap off
SET heading off
SET linesize 300
SET echo off
SET pages 999
SET long 90000
Col object_type format a10000
Col object_name format a10000
Col owner format a10000
spool export.out
SELECT DBMS_METADATA.GET_DDL(object_type, object_name, owner)
FROM all_OBJECTS
WHERE OWNER = 'DMALM'
and object_type not like '%PARTITION'
and object_type not like '%BODY'
and object_type not like '%LOB';
spool off
quit
但我收到的输出文件是在col#80切割的。 如何防止输出文件被包装?
答案 0 :(得分:6)
您还需要:
SET longchunksize 90000
数据类型列的默认宽度是数据库中列的宽度。
LONG
,BLOB
,BFILE
,CLOB
,NCLOB
或XMLType
的列宽默认为SET LONGCHUNKSIZE
的值或SET LONG
,以较小者为准。
您已经设置了LONG
,但LONGCHUNKSIZE
的默认值仍为80,因此您需要增加该值才能匹配。您可以使用show all
查看所有当前设置。
这会保留换行符和缩进applied by default。
答案 1 :(得分:2)
如何使用word_wrapped?
SET trimspool ON
SET heading off
SET linesize 300
SET echo off
SET pages 999
SET long 90000
set termout off
column txt format a121 word_wrapped
Col object_type format a10000
Col object_name format a10000
Col owner format a10000
spool export.out
SELECT DBMS_METADATA.GET_DDL(object_type, object_name, owner)txt
FROM all_OBJECTS
WHERE OWNER = 'DMALM'
and object_type not like '%PARTITION'
and object_type not like '%BODY'
and object_type not like '%LOB';
spool off
quit
答案 2 :(得分:0)