防止SPOOL的输出被包裹

Fil*_*ppo 4 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
Run Code Online (Sandbox Code Playgroud)

但我得到的输出文件是在col#80切割.如何防止输出文件被包装?

Ale*_*ole 6

你还需要做:

SET longchunksize 90000
Run Code Online (Sandbox Code Playgroud)

正如文件所说:

数据类型列的默认宽度是数据库中列的宽度.的列的宽度LONG,BLOB,BFILE,CLOB,NCLOBXMLType默认的值SET LONGCHUNKSIZESET LONG两者中的较小者.

您已经设置LONG,但LONGCHUNKSIZE仍然保持默认值80,因此您需要增加该值才能匹配.您可以看到所有当前设置show all.

这样可以保留默认应用的换行符和缩进.


Fab*_*llo 1

使用 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
Run Code Online (Sandbox Code Playgroud)