Lesson 1: Generating a SQL script from a database model

In this lesson, you will generate a SQL script from a database model.

  1. If the tutorial database is already running, go to step 2.

    If the tutorial database is not running, in the WorkSpace Navigator, expand the folder MySybStore_Tutorials/Setup/Database. Right-click startMySybStore.bat and select Open With|System Editor to start the tutorial database.

    You should see the Adaptive Server Anywhere icon in your Windows system tray.

  2. If a connection to the SybStore tutorial database is already established, skip to step 3. When there is a successful connection, you see a database icon below the SybStore connection profile in the Enterprise Explorer.

    If you are not connected, in the Enterprise Explorer, right-click the MySybStore connection profile, which you created in the tutorial setup, and select Connect to connect WorkSpace to the tutorial database.

  3. Select Window|Open Perspective|Enterprise Modeling from the main menu bar to open the Enterprise Modeling perspective.

  4. In the WorkSpace Navigator, expand the Models folder and double-click MySybStoreDBModel to open the database model file.

  5. When the database model opens in the editor, double-click the arrow between the two table diagrams to open the Reference Properties window.

    No action is required; after reviewing the properties, click OK to close the dialog box.

  6. Select Database|Generate Database from the main menu bar.

  7. When the Database Generation dialog box opens, complete these options:

  8. Choose the Selection tab.

    The Tables page lists all of the tables available for selection in the model. By default, all tables are selected.

  9. Click OK. Progress of the script-generation process is shown in the Modeling Output view, below the modeling editor.

  10. When the script-generation process finishes, a Generated Files result box appears, showing the path of the generated script file. Click Close to remove the result box.

  11. To view the generated script, in the WorkSpace Navigator, expand the folder MySybStore_Tutorials/Models. Double-click the SybStoreDB.sql script file. The SQL Editor displays the generated script.

  12. Review the script. No action is required. Once you have reviewed the script, select File|Close on the WorkSpace main menu to close the SQL editor.

  13. To close the perspective, select Window|Close Perspective from the WorkSpace main menu bar. You have generated the SQL script to create the database and the database objects you defined in the database model.