Formatting SQL statements

The workflow assistant for query tuning can format an SQL statement so that you can better understand the structure of that statement.

Before you begin

About this task

In many cases, when you capture a query for tuning, the text of the query is not well formatted. The workflow assistant for query tuning can format the query so that each table reference, each column reference under in the SELECT clause, and each predicate, is shown on its own line.

You can expand and collapse sections of complex queries, such as query blocks and subqueries, to see an overview of the query and drill into parts of the query in more detail. When you click any line in the formatted query, other lines of the query that contain column or table references from the same table are also highlighted. You can also customize the formatting by ordering the predicates according to various criteria such as local predicates or join predicates, table references, and highest filter factor.

If you are using Optim™ Query Tuner or Optim Query Workload Tuner: The workflow assistant annotates a formatted query with various statistics. For a full list of these annotations, refer to the help for the Review Formatted Query page. Open this help by clicking the Help button at the top of the page. You can also press F1.

Procedure

On the Run Single-Query Advisors and Analysis Tools page, either click the Run Default Advisors and Tools button, or click the Select What to Run button and select Query Format and Annotation.

What to do next

The workflow assistant for query tuning opens to the Review section. If the Review Formatted Query page is not open, click Open Formatted Query on the left side of this section.

For help on this page, click the Help button at the top of the page. You can also press F1.


Feedback