We help IT Professionals succeed at work.

How to script out a table definition in Oracle Sql developer

brgdotnet
brgdotnet asked
on
In Oracle Sql developer, how do you script out a table definition, so that when you want to create the table in another database, you don't have to create the table manually?
Comment
Watch Question

Most Valuable Expert 2012
Distinguished Expert 2019

Commented:
I would probably do it with straight SQL:
select dbms_metadata.get_ddl('TABLE','YOUR_TABLE_NAME') from dual;

https://docs.oracle.com/database/122/ARPLS/DBMS_METADATA.htm#GUID-A4683EEE-6F54-4081-B7BF-1496096675FA

If you want the SQL Developer way:
http://www.oracle.com/technetwork/developer-tools/sql-developer/export-intro-1-161239.html
Oracle dba
Top Expert 2009
Commented:
there is also the change management solutions
where you only work on the test database and then move items to production via such a change management solution

https://www.red-gate.com/simple-talk/blogs/how-mature-is-your-database-change-management-process/

look for change management on google

all depends how far you need this to go
if you have an audit department which completely forbids IT to go on production, then you have a big shop which will have to go like the solution above
smaller shops usually go the scripting direction

it helps to have a secondary "QAS" (or quality or upgrade) database on which the scripts can be tested.

for bigger scripts i activate flashback database on a qas database
this allows us to return the qas database into a "before the script screwed up" runs state and this process is repeated until the devs are satisfied and they have gotten their flawless go-live script