Executing SQL Statements and Scripts

See Also

You can use the SQL Editor to write and execute SQL statements and SQL scripts within the IDE. The SQL statement or script is executed on the database that is selected in the Connection drop-down list in the toolbar. If the database connection is closed, the IDE opens the connection to the database. In the Connection drop-down list, you can change the database on which you want to run the SQL statement.

You can use the SQL Editor to create, edit and execute any SQL files in your project. To open an SQL file, right-click the SQL file (  SQL File ) in the Projects or Files window and choose Open. You can also double-click the icon to open the file in the SQL Editor.

You can run SQL statements directly from an SQL file, without opening it.

To run an SQL file:

  1. Confirm that the target database server is running.
  2. Open the Favorites window by choosing Window > Favorites.
  3. Right-click inside the Favorites window and choose Add to Favorites. Add the directory that contains the SQL file you want to run.
  4. Right-click the SQL file and choose Run file.
  5. Select a database from the list of registered database connections. Click OK.
    The SQL script will be executed on the selected database connection.

To create and execute a SQL statement or script:

  1. Expand the Databases node in the Services window.
  2. Right-click the node for the connected database and choose Execute Command from the pop-up menu to open the SQL Editor.
  3. Make sure your current database connection is selected in the Connection drop-down menu. To see the status of the listed connections, click the Select Connection in Explorer icon ( Select Connection in Explorer ) in the toolbar. When you click Select Connection in Explorer, the selected connection is highlighted in the Services window.
  4. Enter a DDL or DML statement in the SQL Editor window.
  5. Click Run SQL Run SQL  in the toolbar or right-click in the SQL Editor and choose Run Statement from the pop-up menu.

When you execute an SQL statement or script, you see the following:

Notes:

See Also
Connecting to a Database
Viewing Data in a Database Table
Defining Database Explorer Debug Mode
Creating a Database Table
SQL History

Legal Notices