Creating and Executing an SQL Query

This procedure describes how you can run an SQL query on your database once you have created it.

You must have created a Connection Profile and connected to your database before using this functionality.

 

 

Instructions on how to complete a procedure

To run an SQL Query on your database:

  1. Open the Database Development perspective by going to Window | Open Perspective | Other | Database Development.

  2. Connect to your Database by following the steps in the Connecting to a Database topic.

  3. Click the Open Scrapbook icon on the toolbar.
    A new SQL scrapbook will open.

SQL File editor

  1. There are two ways to write an SQL query:

  2. Writing an SQL query in the scrapbook  (e.g. select * from mytablename;)

  3. Using the SQL Query Builder which builds your queries using a graphical interface:

  1. Right-click in the scrapbook and select Edit in SQL Query builder -or- press Alt + Q.
    The SQL Query Builder will open.

  2. Right-click in the left middle pane and select Add table.

  3. Choose the table(s) from which you would like to build your query.
    The tables and their columns will be displayed in the pane.

  4. Mark the checkbox of the columns to use in your statement.

  5. You can join tables by dragging the cursor between the required queries -or- right-clicking and selecting Create Join. This will allow you to retrieve data from two or more tables based on matching column values.

SQL Query Builder

  1. Your query will be automatically built and displayed in the top pane.

  2. Once you have built your query, click OK.
    For more information, see ' SQL Query Builder ' in the Data Tools Platform User Documentation .

  1. Write your query in the scrapbook (e.g. select * from mytablename;)

  2. To execute your query, right-click anywhere in the editor and select Execute All -or- press Ctrl+Alt+X.
    To execute only specified queries, highlight the relevant lines, right-click and select Execute Selected Text.

The query will be run and the results will be displayed in the Result1 tab in the SQL Results view.

The left pane displays the execution history. For each statement that you execute, including stored procedures, an execution history entry is added to this pane. This allows you to quickly retest the execution using slightly different values and settings. You can rename or delete the launch configurations as needed.

SQL Results view

For more information on the Data Tools Platform, please see the Data Tools Platform User Documentation.