Reputation: 609
I'm new to Oracle and learning about tables using the HR db, i wanted to ask does there exist any command to view the query used to create the predefined tables? (I am not talking about the Desc/ribe command). Thanks in advance
Upvotes: 1
Views: 1358
Reputation: 22467
There is a client-side command, if you're using SQLcl or SQL Developer
ddl *table_name
*
I talk more about it here
Upvotes: 1
Reputation: 222682
You can use the getddl()
function from the dbms_metadata
package.
As an example, the following query gives you the DDL for table mytable
in schema HR
:
select dbms_metadata.get_ddl('TABLE','MYTABLE','HR') from dual;
If you want the information for all tables in the HR
schema at once, you can do:
select table_name, dbms_metadata.get_ddl('TABLE', table_name, owner)
from all_tables
where owner = 'HR';
Upvotes: 3