Prev Next

SQL Scratch Pad

The SQL Scratch Pad provides a mechanism to develop and run ad-hoc SQL Queries against a live database. While you develop your data model you might want to execute and test ad-hoc SQL Queries for a DDL script, or run enquiries on the live database; all of this is possible within the Enterprise Architect Database Builder interface.

The SQL Scratch Pad requires the Database Builder to have a valid ODBC connection to a live database. This database connection is shared between the 'SQL Scratch Pad', 'Database Compare' and 'Execute DDL' tabs of the Database Builder.

The Scratch Pad consists of:

  • A toolbar providing facilities for importing, saving, executing and clearing the SQL Queries
  • An editor panel in which you create or import the SQL Queries - this panel provides SQL-based syntax highlighting for the current data model
  • A tabbed panel consisting of two pages, one to show the results of executing the Query and one to display any messages generated during the execution

Access

Open the Database Builder window, then display the 'SQL Scratch Pad' tab.

Ribbon

Specialize > Tools > Database Builder > SQL Scratch Pad

The Scratch Pad Toolbar

The functionality of each button on the Scratch Pad Toolbar is described in this table, working from left to right.

Button

Action

Run SQL

Executes the SQL Query currently shown in the Scratch Pad.

Check the 'Results' and 'Messages' tabs for the output of executing the Query.

New

Clears the SQL Query editor fields so that you can enter a new query.

Open

Loads an SQL Query from file.

A source file browser displays, defaulted to display SQL files. Click on the file name and on the Open button to display the file contents in the Scratch Pad.

Save to SQL Query

Saves this SQL statement to the SQL Query object it came from.

Save to New SQL Query

Creates a new SQL Query object and saves this statement to that object.

Save to File

Saves the currently-displayed Query to the file it came from.

If you created the Query from scratch, a source file browser displays in which you type the new file name and click on the Save button to save the Query.

Save to New File

Saves the currently-displayed Query to a new .sql file.

A source file browser displays on which you type in the new file name and click on the Save button to save the Query.

Clear

Clears the contents of the Scratch Pad.

Any Query displayed in the Scratch Pad remains there until you either replace it with another Query from file or you close the model.

Toggle Comment

Applies the SQL comment characters '--' to the beginning of each selected line or, if the selected lines are already commented, removes the comment characters. Alternatively, press Ctrl+Shift+C.

Statement Separator

Type in the character(s) to use to mark the end of each statement.

Help

Displays the Help on the SQL Query Scratch Pad.

Query Description

Displays a label providing a description of the current SQL, whether there are pending changes (indicated by a leading *), and the name of the loaded SQL Query object or Filename.

Notes

  • The SQL Scratch Pad does not manipulate your SQL in any way, so you must use the correct syntax for the current DBMS
  • While the SQL Scratch Pad can execute multiple SQL statements, and the status and messages of each statement are shown in the 'Messages' list, only the results of one SELECT statement can be shown in the 'Results' list at a time; all subsequent SELECT statements will be ignored

Learn more