5

我正在尝试使用 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

但是我得到的输出文件在第 80 列被剪切。如何防止输出文件被包装?

4

3 回答 3

8

你还需要做:

SET longchunksize 90000

正如文档所说

数据类型列的默认宽度是数据库中列的宽度。LONGa 、BLOBBFILE、或的列宽默认为 或 的值,CLOB以较小者为准。NCLOBXMLTypeSET LONGCHUNKSIZESET LONG

您已经在设置LONG,但LONGCHUNKSIZE仍处于默认值 80,因此您需要增加该值以匹配。您可以使用 来查看所有当前设置show all

这会保留默认应用的换行符和缩进。

于 2014-08-05T15:57:51.130 回答
2

How about using 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
于 2014-08-05T15:56:40.133 回答
1

听起来您可能想尝试:

set longchunksize 100

或同等学历。试验一下这个数字,看看它是否有帮助。

Oracle 文档

于 2014-08-05T15:58:23.057 回答