防止SPOOL的输出被包裹

时间:2014-08-05 15:36:30

标签: oracle sqlplus spool

我尝试使用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切割的。 如何防止输出文件被包装?

3 个答案:

答案 0 :(得分:6)

您还需要:

SET longchunksize 90000

作为the documentation says

  

数据类型列的默认宽度是数据库中列的宽度。 LONGBLOBBFILECLOBNCLOBXMLType的列宽默认为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)

听起来你可能想尝试一下:

set longchunksize 100

或同等学历。试验数字是否有帮助。

来源Oracle Docs