Lesson 1: Opening and executing a SQL script

In this lesson, you will execute a MySybStore database SQL script. You must first complete “Creating, editing, and executing SQL files”.

  1. If the Database Development perspective is already open, continue to the next step.

    If the Database Development perspective is not open, select Window|Open Perspective|Database Development from the Sybase WorkSpace main menu bar.

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

    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.

  3. If a connection to the SybStore tutorial database is already established, go to step 4. When there is a successful connection, you see a database icon below the SybStore connection profile.

    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 Sybase WorkSpace to the tutorial database.

  4. In the WorkSpace Navigator, expand the MySybStore_Tutorials/Setup/Database/SQL folder and double-click the SybStoreDB.sql file.

    Sybase WorkSpace displays the SQL script contents in the SQL editor.

  5. In the WorkSpace Navigator, right-click SybStoreDB.sql, and select Execute SQL File from the context menu.

    You see the Select Profile for the Editor dialog box.

  6. Complete these fields:

    Once you make these selections, the Database Name is automatically filled in.

  7. Click OK. When execution completes successfully, the following output appears in a SQL Results pane that displays in the Sybase WorkSpace main window.

    Each line in the history pane (on the left) displays the summary information on statements executed in the SQL script.

  8. In the SQL Results pane, click a SQL statement line on the left to view that statement’s detail on the right below the Status Detail tab.

  9. Close the SQL Results pane by clicking the “X” on the title tab. You have finished running a SQL script on a database server.

Leave the SQL editor open for the next lesson.

NoteTo execute a subset of a SQL script, select only the statements you want to execute, then right-click and select Execute Selected Text from the context menu.