9.7 TipsAndTricks ToadForOracle
9.7 TipsAndTricks ToadForOracle
Introduction
Toad for Oracle is now celebrating its 10th year of being the market leading Oracle tool
for database p professionals. Whether you are new to Toad, or have been using it for the
past decade, there are several features that we feel you should be familiar with. This
document will step you through some Toad fundamentals. We break down the features
by the following areas:
Standard features – discusses functionality provided by the base edition of Toad
Xpert features – discusses our proprietary SQL and Index optimization features
Database Administration features – discusses how Toad can help a DBA or
Development team manage their Oracle environments with Toad.
If you are already a Toad customer and do not have access to the features being discussed
below, please contact your Quest Sales Representative and request a complimentary 30-
day evaluation license key.
This section also discusses Toad‟s powerful features available for developing and
maintaining your PL/SQL stored procedures.
2) Display Type Configure Toad to show your objects in a Tree List, Drop Down
list, or using a Single Line of tabs.
Selecting ‘Dropdown’ will give you the most amount of real estate for listing
objects and allow you to use the keyboard to navigate the object type list.
3) Favorites Add regularly accessed objects to the favorites tab by right clicking on
the object and selecting Add to SB Favorites.
4) Projects Organize your database objects by Application or Project by right
clicking on an object(s) and selecting „Add to Project Manager‟. Having a Project
defined will allow you to now filter your object list by Project. This can be handy
when you are logged into a 30,000+ object schema that contains tables for 30
different applications and you only want to see the „Payroll‟ tables versus
everything.
5) History Quickly navigate to objects you‟ve browsed to previously. Use the
„Sundial‟ button
6) Data View and modify a table‟s data by selecting table from the object tabular
view, and the DATA from the right side of the screen
a) Sort/Filter the data by selecting the icon resembling a funnel
b) Select Columns- to limit the columns shown in the grid right click and
choose SELECT COLUMNS
c) Save the data to a file format of your choice by right clicking in the data
grid and selecting Save As. This gives the choice of format and saving the
data to a file or copying to the clipboard.
d) Create Insert Statements by right clicking the data grid and selecting
create insert statement. It will save inserts on clipboard to be run from
Editor.
e) Customize Layouts by dragging and dropping columns into select order.
Fix a column or set of columns by right clicking and selecting fix current
column. View only desired columns by right clicking and choosing select
columns. To save a desired layout, select VIEW>OPTIONS>SCHEMA
BROWSER> DATA and GRIDS>DATA GRIDS and check „Save
Layouts‟
f) Card View allows you to view records one a time vertically. Click on the
„Blue Book‟ button to start using this feature.
7) Additional Detail View New for version 9.5, we now display by default all of the
detail information for your objects on the Right-Hand-Side (RHS). You can
manually add any of these detail items to the LHS by mouse-right-clicking in the
column header on the LHS. For example you could add „Num Rows‟ and sort by
table size.
3) Choose Columns Double click in the check boxes of the columns desired for the
query
4) Add Where Clause Criteria Drag a selected column from the „SELECT‟ tree
area and drop it on the „WHERE‟ area. You can also mouse-right-click on a
column in the tree and select „Include in Where Clause.‟ This will open the
„Where Definition‟ window. Click on the ellipsis button to see distinct values for
the selected field to help you build a meaningful where condition.
5) View Generated Query View the SQL by looking at bottom of the screen.
6) Run Generated Query Run the query with the F9 key or the green play button to
return a data set.
7) Explain Plan View the explain plan by clicking on the ambulance icon on the
second of the top two icon bars
8) Create a model from existing Query- From the Editor right click and select
“Send to Query Builder” to reverse-engineer your selected query to a Query
Builder model.
Editor the former SQL Editor, PLSQL Editor, and offline editors have been condensed to
a single window for all of your SQL, PL/SQL, anonymous block, SQL*Plus script, XML,
etc editing and ad hoc querying the database.
1. SQL Recall Access previously executed SQL by selecting F8. This will put a
“Slide in slide out” SQL recall button on the left side of the Editor. The user can
filter the list by adding to “Personal SQLs” or take it a step further by adding to
“Named SQL” both of which are found under the SQL Editor menu option. To
select Personal and Named SQL, right click the statement and select “Change to
Personal” or “Change to Named.”
a. Named SQL Giving your SQL Statements a name allows you to recall
your query by context versus obscure SQL you may have wrote 6 months
ago. If you spend more than 30 seconds writing a SQL statement, give it a
name. You can now recall w/o using the F8 dialog giving you more room
to type in the editor. Use <CNTRL>+N to popup a list of named SQL
statements. Selecting one will put the SQL in your editor.
b. Quick Browse You can cycle through your list of previously written SQL
statements using <ALT>+<Up Arrow> or <ALT>+<Down Arrow>. You
can do this on selected text to do a limited replacement.
2. Table and Column Windows From the VIEW menu select the „Object Pallete‟
- this will invoke a sliding/dockable window displaying Tables and Columns.
Once these windows are slid into view, drag and drop or double-click mouse
functionality can be fully utilized. Another manner for retrieving table names is
by selecting the first letter or letters of the table and hitting
<CTRL>+<Period>. To access a table, or ANY other object description, place
the cursor on the text and hit F4.
3. SQL Function Templates From the VIEW menu select the CODE SNIPPETS
this will invoke a sliding/dockable window displaying code templates. A drop
down let‟s us see all of the different Function Types from which we can select
templates. Drag and drop can also be utilized from this dockable window.
4. Make Code Statements TOAD supports 6 different programming languages
(C++, Delphi, Perl, etc), chosen through the Options menu, for creating code
statements based on SQL, or for stripping non-SQL syntax from a code statement.
To take a SQL statement and automatically format it to be imbedded into a Java
program, for example, we need to simply select “Make CODE Statement” from
the Editor menu. This will copy the current window‟s statement to the clipboard
in whichever language‟s syntax the user has chosen. The next step is to paste the
formatted SQL call into the code. You can extend this feature to the
programming language of your choice by adding it manually in the Options
dialog.
5. Format Code To instantly transform chaotic, untidy code into easily managed
aesthetically pleasing code by right clicking in the editor and selecting the icon
showing two yellow arrows. Under the menu option “View”, select “Formatting
Options” to customize how the code will be formatted.
6. Auto Replace To access the auto replace, right-mouse-click from the editor and
select “Editing Options”. From there choose “Auto Replace” to set what the user
wants replaced and with what to replace it.
7. Code Templates You can customize the pre-written code templates by right-
clicking in the Editor and choosing “Editing Options.” From there you will
default into the behavior portion of the Editor options. From the Language area,
choose edit, and you will see a number of templates to edit. Select Templates to
see, add and edit you templates. Toad provides many templates but the user can
also add their own templates from here. To access the Templates from the Editor
simultaneously press <CTRL> and the Space Bar. The user can also memorize the
shortcut name, type one and hit CRTL/Space to retrieve the Template.
8. Code Insight Toad can help you write your SQL and/or PL/SQL statements. The
Code Insight feature has been remarkably improved for the 9.6 release. As you
may remember from Toad v 9.5, Code Insight (<ctrl>+<Period> from the editor)
allows you to quickly browse and select tables in the editor. Now in 9.6, Code
Insight has the ability to see the following object types:
a. Tables
b. Views
c. Aliases
d. Functions|Procedures|Packages (with methods)
e. Types (with attributes and methods)
f. Java Source
g. Sequences
h. Users
i. Public Synonymns
Any child nodes of an object will be displayed when „.‟ is used after the
insight window has been opened.
j. Special Note: for performance reasons, not all of the above are enabled by
default, in particular the public synonym type.
Quickly determine which line of code is taking the most time to run.
Toad can even detect poorly written SQL code that could affect performance in
production environments!
Querying Databases other than Oracle- Introducing Toad for Data Analysis
1. Connect natively to the following non-Oracle databases:
a. IBM‟s DB2, LUW and z/OS
b. Microsoft SQL Server
c. MySQL
d. Sybase ASE
2. Connect via ODBC to other databases, including:
a. Terradata
b. Informix
c. PostreSQL
d. Any datasource that supports the ODBC v3 protocol
3. Quick connect to MS Access and MS Excel w/o ODBC configuration for
querying, reporting, and exports/imports!
4. Build queries visually or use the familiar Toad editor to get to your data
5. Browse the contents of the database using a single Browser (just like Toad for
Oracle!)
6. Compare and Synch DATA between different databases
7. Rich MS Excel integration, build pivot tables and ODBC linked queries on the
fly!
Toad for Oracle now includes Toad for Data Analysis which extends our powerful
browsing and querying technology to other RDBMS platforms!
Toad’s Professional edition allows you to select one or more tables and generate
test data. Toad will even honor your foreign key relationships when creating key
values.
Generate functional tests for your PL/SQL without writing any PL/SQL code
Describe in plain English the behavior of your PL/SQL program, and let Toad
generate and manage your test code. Run a regression test anytime you make a
change to your program. This feature is available with the Toad Development
Suite for Oracle.
Toad for Oracle‟s Xpert Edition includes a comprehensive SQL Tuning solution which
will identify problematic SQL, Optimize statements automatically, suggest index
alternatives, and even provide impact analysis when making changes that affect the
database.
Wherever you encounter SQL in Toad, you can also invoke a tuning session for that
statement by simply pressing the “Optimize SQL” button.
Batch Optimizer- The tuning technology now allows a user to send multiple
tuning jobs (any collection of SQL or any embedded SQL found in a set of PL/SQL
programs) to a tuning queue. Each section of code will be evaluated. Any „problematic‟
SQL code will be automatically tuned. You will be informed what SQL the tuner was
able to generate that will allow your query to run faster, and by how much!
Toad’s Batch Optimizer can take a collection of poorly performing SQL statements and
tune them in batch. We’ll provide the new queries and show you then increased
performance and before and after execution plans.
The tuning technology was updated for v9.5 of Toad. Starting with version 9.6, when
starting a new tuning scenario, users will be prompted to add their SQL to the Batch
Optimizer Queue, or by starting a new Tuning Lab session. The Tuning Lab session will
allow the user to tune the SQL by hand just like it worked in versions 7-9.1 of Toad.
Tuning Lab- The Tuning Lab, or the „classic Tuning window‟, guides the user
through analyzing the current execution plan and then to generating SQL query rewrites
that will hopefully find a different execution plan that positively affects the execution
time. Toad offers an easy-to-understand execution plan which is automatically generated
when a statement is moved into the Tuning area.
Toad takes selected tuning techniques like syntax transformation, hints, where clause
order permutations, etc to generate new queries that force Oracle to consider new
execution plans for your queries.
Impact Analyzer – Whenever you add one or more indexes to the database,
the execution plans for your applications‟ embedded SQL can be dramatically impacted.
The Impact Analyzer allows you to model these proposed system changes so you can see
exactly how your new index affects everything else in the database. We generate the new
theoretical index and the new execution plans for each of your production SQL
statements. You can see what the before and after ramifications are to your system
whenever you propose a change.
Identify key SQL code, propose a change to the system (a new index?), then see how that
change affects the execution plans for your SQL code.
Database Management Made Easy via the DB Admin
Module
Any copy of Toad can be upgraded to include Toad‟s advanced database object
management features with the DB Admin module. Whether you need to create test
environments based on existing instances, manage database resources, or compare and
synchronize different instance, the DB Admin module may be right up your alley. This
portion of the document will take you through some of the more helpful features.
Easily create multiple types of health check scans that run on selected instances on given
days of the week and email the results to the DBAs responsible for those
instances/database tasks.
The Database Browser serves as your entry point to running most of the database level
utilities in Toad. Start a health check, look for the most expensive sessions, startup or
shutdown the instance, all with a single click. New for version 9.7, Toad now offers the
ability to setup and run your database backups with our Recover Manager (RMAN)
integration.
Trace File Browser (Database > Diagnose > Trace File Browser)
Tired of using TKprof to analyze your trace files to see what is causing your database to
run at less than peak performance? New for Toad v9.7, you can now visually inspect the
contents of your Trace files. See immediately all of the queries captured with their binds,
waits, and performance profiles.
Click on a query to see the binds variables and the values passed for execution.
Toad will show the number of queries that run under specific amounts of time. Drill
down to an individual statement to see the Execution vs Parse vs Fetch vs Wait times so
you know EXACTLY how to approach a tuning scenario.
All of the following are available with Toad in our Toad DBA Suite for Oracle.