0

I am wondering what the analog of the below teradata code is in Oracle. I want to find the underlying table or view ETL code. Basically, I want to find the code that is used to create the table/view. Is there a query to do this? Please send this code. I only know how to do this in the schema browser. I am using ORacle SQL Developer, Schema Browser. Then clicked on SQL. I was looking for the underlying SQL on this table. This is the SQL code that creates the view. THis is the DDL. I just wanted to know how the view was created similarly, the analog to teradata code.

teradata
show VIEW Schema.Table
oracle
?
  • This Worked!!!! `select text from ALL_VIEWS where upper(view_name) like upper('TABLE');` –  Oct 30 '18 at 19:40
  • if you're in the admin (sys or system schema) you can use all_views instead of user_schema which works for an ordinary schema where your related view exists. So if you connect to the right schema, @Hady Lattouf 's solution works also. By the way, `upper` is superfluous provided the table name in all capital letters such like `select text from all_views where view_name = 'MY_VIEW'` – Barbaros Özhan Oct 30 '18 at 19:49

2 Answers2

1

For views please execute this query:

select text from user_views where view_name = 'EMP_VIEW';

For tables you can execute this query:

select dbms_metadata.get_ddl( 'TABLE', 'EMP', 'SCOTT' ) from dual
0

Oracle has a package DBMS_METADATA which is can be used to exctract DDL command to create it. You can use GET_DDL function to get table definition.

SELECT DBMS_METADATA.GET_DDL( 
           object_type => 'TABLE', 
           name => 'Table' , 
           schema => 'Schema') 
FROM DUAL;
Jacek Wróbel
  • 1,172
  • 10
  • 17