简体   繁体   中英

Simple Queries in Oracle

what are the queries to do the following in Oracle?

  1. get names of all views which are present ? (Similar to select * from view, but i want to get views not tables)
  2. See source of a particular view.
  1. get names of all views:

    a. which are owned by the current user:

     SELECT view_name FROM USER_VIEWS; 

    b. which are visible to the current user:

     SELECT view_name FROM ALL_VIEWS; 

    c. which are present:

     SELECT view_name FROM DBA_VIEWS; 
  2. See source of a particular view

    SELECT text FROM xxx_VIEWS WHERE view_name = :myviewname;

(xxx can be USER, ALL or DBA)

DBA_VIEWS

要在sqlplus中查看视图的定义:

describe MY_VIEW;

This query will get the names of views in your schema.

select object_name
  from user_objects
 where object_type = 'VIEW'

The query for getting the view source?

SQL> select dbms_metadata.get_ddl('VIEW', 'VIEW_NAME', 'USERNAME')
 2     from dual
 3   /

views owned by user

 select * from USER_VIEWS ;

check for oracle objects metadata

http://cisnet.baruch.cuny.edu/holowczak/oracle/sqlplus/

1. select  OWNER,
 OBJECT_NAME,
 to_char(CREATED,'MM/DD/YYYY HH24:MI:SS') created,
 status
from   dba_objects
where OWNER not in ('SYS','SYSTEM')
and OBJECT_TYPE='VIEW'
order by OWNER,OBJECT_NAME

  1. select TEXT FROM DBA_VIEWS where OWNER ='owner_name' and VIEW_NAME= 'view_name'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM