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 menu in the toolbar.
If the database connection is closed, the IDE opens the connection to the database.
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 (
) in the Projects or Files window and choose Open.
You can also double-click the icon to open the file in the SQL Editor.
To create and execute a SQL statement or script:
- Expand the Databases node in the Services window.
- Right-click the node for the connected database and choose Execute Command from the pop-up menu to open the SQL Editor.
- 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 (
) in the toolbar.
When you click Select Connection in Explorer, the selected connection is highlighted in the Services window.
- Enter a DDL or DML statement in the SQL Editor window.
- Click Run SQL
in the toolbar or right-click in the
SQL Editor and choose Run Statement from the pop-up menu.
- Note: When you execute SQL in the SQL Editor, normally the results tabs from the previous execution are closed. You can change this behavior so
that the previous tab remains open. To do this, click Keep Prior Results (
) in the tool bar. This setting is saved for all subsequent SQL executions, or until you toggle it off again.
When you execute an SQL statement or script, you see the following:
- The status of the SQL execution is displayed in the Output window.
Any errors when executing the SQL statement or script are displayed in the Output window.
- The output of the statement appears in the results pane in the lower half of the SQL Editor.
If the statement has no output, the number of affected rows is displayed in the Output window of the IDE.
Notes:
- You can run selected text in the SQL Editor by right-clicking the selected
text and choosing Run Selection from the pop-up menu.
- You can access the Execute Command pop-up menu item from any subnode of a connected database (
) in the Services window.
- To view the data in a table, right-click a table in the Services window and choose View Data from the pop-up menu.
For more, see Viewing Data.
-
See Also
- Connecting to a Database
- Viewing Data in a Database Table
- Defining Database Explorer Debug Mode
- Creating a Database Table
Legal Notices