Hello. And welcome to this presentation on Toad Data Modeler Version 5. Today, I'm going to show you how to generate SQL code for your models.
In this demonstration, I will use the video rental sample model. It's a relatively small model with several workspaces. Each workspace contains a different number of tables, views, and other objects.
How to generate SQL code-- press F9 key or click the Generate DDL Script icon on toolbar. DDL Script Generation form opens. On [INAUDIBLE] what to generate, specify path to the output file. If you need to generate SQL code for a specific schema, select the appropriate item in the user schema combo box.
Select what object types you wish to generate. And select Drop, Create, or Drop and Create type of SQL statements. You can set the values one by one or use the combo box above to create.
On tab Detail Settings, specify advanced options that are available for the selected target database-- in this case, for Oracle 10g. You can use quotation marks, create indexes to foreign keys, and so on.
In case you need to change the order of generated objects-- for example, if you know that some function should be generated before stored procedure creation statements-- click the Edit button. New form opens. Select items you wish to move up or down. And use the green arrow icons on the toolbar to change the order.
On the same form, you can specify how keys, indexes and some other supported objects should be generated. To change the values, select the item in the grid and press F2 key to enable combo box with available options. Select appropriate option and click OK to confirm changes.
On tab Referential Integrity, specify rules for a referential integrated generation. On this tab, you can define if referential integrity code should be generated only if both the tables are generated. In other words, if you generate SQL code just for the one selected workspace, both the tables must be members of that workspace.
On the last tab, select list, define instances of objects. There are several methods how to specify a list of the generated objects. Using the Generate property, if you edit any object in Toad Data Modeler and uncheck the Generate checkbox, the object will be displayed with small icon in the right bottom corner and the item will appear on the SQL Code Generation form as Not Selected.
Another option you have to generate SQL code for the selected workspace. Uncheck this checkbox and set the workspace from the combo box. All items will be listed in the grids. And you can select items from the whole model one by one.
When all the settings are set, click button Save Settings and store the settings to your model file. Next time when you open the form, the same settings will be loaded.
To verify your model, click button Verify. If you wish to display a preview, select Show Preview checkbox. And to generate SQL code, click button Generate. Toad Data Modeler will generate SQL code for you.
Here, we can see a preview of the generated SQL code. If you want to open the generated file once again, click Show Code. By default, internal SQL Code Viewer opens. If you want to open the generated file in a custom editor, click Settings, Options, and in Physical Model section, specify your custom editor.
In this section, it is possible to define encoding for the generated files as well. In case you need to use one custom editor for Oracle and another for SQL Server, for example, select the appropriate target database and specify custom editor just for the platform.