4.8 Use the SQL Worksheet for Queries

You can use the SQL Worksheet to test SQL statements using a database connection.

  1. In the right pane, enter the following statement (the semicolon is optional for the SQL Worksheet):

    SELECT author_last_name, title FROM books;

    Notice the automatic highlighting of SQL keywords (SELECT and FROM in this example).

  2. Click the Run Statement icon in the SQL Worksheet toolbar. The results of the query are displayed in the Query Result tab under the area in which you entered the SQL statement.

  3. Enter (or copy and paste) the following statement:

    SELECT p.patron_id,
           p.last_name,
           p.first_name,
           t.transaction_type,
           t.transaction_date
      FROM patrons p, transactions t
     WHERE p.patron_id = t.patron_id
     ORDER BY p.patron_id, t.transaction_type;
    
  4. Click the Run Statement icon in the SQL Worksheet toolbar, and view the results of the query.

  5. Click the Explain Plan icon in the SQL Worksheet toolbar to see the execution plan (displayed on the Explain tab) that Oracle Database follows to execute the SQL statement. The information includes the optimizer strategy and the cost of executing the statement.