List views in Oracle database with their scripts

Query below lists:

(A) all views, with their definition, accessible to the current user in Oracle database

(B) all views, with their definition, in Oracle database

Query was executed under the Oracle12c Database version.

Query

A. All views accessible to the current user

select owner as schema_name,
       view_name,
       text as script
from sys.all_views 
order by owner,
         view_name;

B. If you have privilege on dba_views

select owner as schema_name,
       view_name,
       text as script
from sys.dba_views 
order by owner,
         view_name;

Columns

  • schema_name - view owner, schema name
  • view_name - view name
  • script - view script - select statement only

Rows

  • One row represents one view in a database
  • Scope of rows: (A) all views, with their definition, accessible to the current user in Oracle database, (B) all views, with their definition, in Oracle database
  • Ordered by schema name, view name

Sample results