Preventing sqlplus truncation of column names, without individual column formatting

前端 未结 6 2342
感情败类
感情败类 2021-02-09 13:13

By default sqlplus truncates column names to the length of the underlying data type. Many of the column names in our database are prefixed by the table name, and therefore look

6条回答
  •  攒了一身酷
    2021-02-09 13:44

    It's a bit of a hack if you don't need or want XML formatting, but you should be able to use the DBMS_XMLGEN package. This script should give you an XML file for an arbitrary query with the full column name as the tag name.

    VARIABLE resultXML clob;
    SET LONG 100000; -- Set to the maximum size of the XML you want to display (in bytes) 
    SET PAGESIZE 0;
    
    DECLARE
       qryCtx DBMS_XMLGEN.ctxHandle;
    BEGIN
      qryCtx := dbms_xmlgen.newContext('SELECT * from scott.emp');
    
      -- now get the result
      :resultXML := DBMS_XMLGEN.getXML(qryCtx);
    
      --close context
      DBMS_XMLGEN.closeContext(qryCtx);
    END;
    /
    
    print resultXML
    

提交回复
热议问题