Get Oracle View Definition with limited control

Using @Marmite's suggestion of DBMS_METADATA.GET_DDL, and assuming the tool you're using only lets you retrieve 100 chars at a time, the following should retrieve your complete view:

SELECT view_name, LEVEL "Line No", 
DBMS_LOB.SUBSTR(view_clob, 100 ,1 + (LEVEL-1)*100) line_text FROM (
    SELECT view_name, owner, 
    DBMS_METADATA.GET_DDL('VIEW', view_name, owner) view_clob 
    FROM all_views WHERE view_name = '<view_name>'
) CONNECT BY LEVEL <= CEIL(LENGTHB(view_clob)/100) ORDER BY LEVEL;

Your problem is the LONG column containing the view definition.

You may use the DBMS_METADATA package to get the view text as a CLOB

select DBMS_METADATA.GET_DDL ('VIEW','view_name','owner') from dual;

Tags:

Oracle

Plsql