Oracle Spool - Missing complere information

你说的曾经没有我的故事 提交于 2019-12-13 06:39:54

问题


I am trying to Spool information from my table metadata. But the text file ends on second line. It doesn't display the complete metadata

SPOOL P_TABLES.txt

set linesize 10000
set trimspool on
set heading on

SELECT DBMS_METADATA.GET_DDL('TABLE','TABLE_X') FROM DUAL;

SPOOL OFF;

It exports a text file but it doesn't provide complete information.

> SELECT DBMS_METADATA.GET_DDL('TABLE','TESI_STAMPDUTYLABELSVALUE') FROM DUAL

CREATE TABLE "ESIXUSER"."TESI_STAMPDUTYLABELSVALUE" 
 (  "SVUNIDOCREFID" VAR...
 //Nothing after this in .txt file.

Where as in Oracle SQL Developer, I am able to check the complete DLL.

Do I do change my linesize in sql file?


回答1:


I am not sure exactly this will work or not but

Click here ( http://www.dba-oracle.com/t_1_dbms_metadata.htm " this may help for you")

I think you are missing these:

set heading off set echo off Set pages 999 set long 90000




回答2:


GET_DDL returns a CLOB, and this may be difficult to directly print. If you need to print your result, you may need something that scans your CLOB printing the rows:

declare     
  vClob clob; 

  PROCEDURE print_clob (
    pClob      IN OUT NOCOPY CLOB
  )
  IS
    kLineTerminator    VARCHAR2(1)   := CHR(10);
    vlgh_file    NUMBER := 0;                                 
    vLineEndPos      INTEGER;
    vROW         VARCHAR2(32767);
    vOffset      NUMBER := 1;

  BEGIN
    vlgh_file := DBMS_LOB.GETLENGTH(pClob);
    --
    while (vOffset < vlgh_file) LOOP
      vLineEndPos := DBMS_LOB.INSTR(pClob, kLineTerminator, vOffset);
      if (vLineEndPos = 0) then
        vLineEndPos := vlgh_file +1 ;
      end if;
      vROW        := RTRIM(NVL(DBMS_LOB.SUBSTR(pClob, vLineEndPos - vOffset, vOffset),'--'));
      vOffset     := vLineEndPos;

      DBMS_OUTPUT.PUT_LINE(vROW);

      vOffset := vOffset + 1;
    END LOOP;
  END print_clob;  
begin
    select  DBMS_METADATA.GET_DDL('TABLE','TEST_DDL') into vClob from dual;
    --
    print_clob(vClob);
end;
/     



回答3:


SET LONG 1000000000
SET LINESIZE 10000
SPOOL ABC.TXT
SELECT DBMS_METADATA.GET_DDL('TABLE','TABLE_X') FROM DUAL;
SPOOL OFF;


来源:https://stackoverflow.com/questions/35983994/oracle-spool-missing-complere-information

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!