Data Definition Language (DDL) is used to create our database objects. You may need to get this DDL code for an object you’ve lost the ‘source code’ for, or perhaps you want to build an script to create something you’ve been putting together with the GUI.
So we have our table, but how would we get the DDL code?
In today’s post, I’ll demonstrate all the different way to accomplish this task using SQL Developer Web. It’ SQL Developer, but in your browser!
So let’s start with an object, in this case my NETFLIX table.
Let’s use code to generate code!
Use the DDL command in the SQL worksheet
Try this with one of your tables.
SET ddl constraints off SET ddl ref_constraints off SET ddl tablespace off SET ddl segment_attributes off ddl NETFLIX
The output is sent to the Script Output panel.
Using the Create/Edit Dialogs
Find your table.
Right click on it.
If you were to make any changes to the object, you would see those as DDL changes in the ‘Update’ panel.
Using the Modeler
It’s not JUST for making pretty pictures!
From the Modeler page, simply press this button and wait. It can take a minute or so…
If you want it for just a few objects, the easiest thing to do is build a model diagram, then ask for the DDL for those objects.
So add your objects, I just drag and drop them over.
Then the DDL Preview button gives me this –
If we look into the options –
Generating DDL in SQL Developer Web’s Data Modeler