Quest Toad for Oracle12.11 User manual
PDF
Documento
Pubblicità
Pubblicità
Toad for Oracle12.11
Getting Started
© 2017 Quest Software Inc. ALL RIGHTS RESERVED.
This guide contains proprietary information protected by copyright. The software described in this guide is furnished under a
software license or nondisclosure agreement. This software may be used or copied only in accordance with the terms of the
applicable agreement. No part of this guide may be reproduced or transmitted in any form or by any means, electronic or
mechanical, including photocopying and recording for any purpose other than the purchaser’s personal use without the written
permission of Quest Software Inc.
The information in this document is provided in connection with Quest Software products. No license, express or implied, by estoppel
or otherwise, to any intellectual property right is granted by this document or in connection with the sale of Quest Software products.
EXCEPT AS SET FORTH IN THE TERMS AND CONDITIONS AS SPECIFIED IN THE LICENSE AGREEMENT FOR THIS
PRODUCT, QUEST SOFTWARE ASSUMES NO LIABILITY WHATSOEVER AND DISCLAIMS ANY EXPRESS, IMPLIED OR
STATUTORY WARRANTY RELATING TO ITS PRODUCTS INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTY
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL
QUEST SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, CONSEQUENTIAL, PUNITIVE, SPECIAL OR INCIDENTAL
DAMAGES (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF PROFITS, BUSINESS INTERRUPTION OR
LOSS OF INFORMATION) ARISING OUT OF THE USE OR INABILITY TO USE THIS DOCUMENT, EVEN IF QUEST
SOFTWARE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Quest Software makes no representations or
warranties with respect to the accuracy or completeness of the contents of this document and reserves the right to make changes to
specifications and product descriptions at any time without notice. Quest Software does not make any commitment to update the
information contained in this document..
If you have any questions regarding your potential use of this material, contact:
Quest Software Inc.
Attn: LEGAL Dept
4 Polaris Way
Aliso Viejo, CA 92656
Refer to our Web site (https://www.quest.com) for regional and international office information.
Patents
Quest Software is proud of our advanced technology. Patents and pending patents may apply to this product. For the most current
information about applicable patents for this product, please visit our website at https://www.quest.com/legal.
Trademarks
Quest, the Quest logo, and Join the Innovation are trademarks and registered trademarks of Quest Software Inc. For a complete list
of Quest marks, visit https://www.quest.com/legal/trademark-information.aspx. All other trademarks and registered trademarks are
property of their respective owners.
Legend
WARNING: A WARNING icon indicates a potential for property damage, personal injury, or death.
CAUTION: A CAUTION icon indicates potential damage to hardware or loss of data if instructions
are not followed.
IMPORTANT, NOTE, TIP, MOBILE, or VIDEO: An information icon indicates supporting information.
Toad Getting Started
Updated - 5/26/2017
Version - 12.11
Toad 12.11 Getting Started
2
Contents
Contents
3
Welcome to Toad™ for Oracle®
About This Guide
10
11
Toad Resources
Jump Search
Toad Advisor
Toad World
Idea Pond
Toad World Forums
Toad Web-based Training
Retrieve License Keys
Create Support Bundles
12
12
14
15
15
15
16
16
17
Required Privileges for Toad
Required Oracle Privileges
Base Edition
DB Admin Module
Windows Privileges and Toad
18
18
18
18
19
Create and Manage Database Connections
About Database Connections
Create or Edit a Connection
Save Connection Passwords
Import/Export Connection Settings
Automatically Connect on Startup
Use Previous Connections
Change Active Connection in Window
Test Connections
End Connections
Commit or Rollback Changes
20
20
21
24
25
25
25
26
26
26
27
Editor Basics
About the Editor
Editor Toolbars
File
28
28
28
28
Toad 12.11 Getting Started
Contents
3
Edit
Execute
Current Schema
Desktop
Macro
Code Analysis
Team Coding
Intelligence Central
Editor Layout
Navigator Panel
Object Palette
Editor
Desktop Panels
Editor Right-click Menu
Shortcut Keys
Editor Results Area
Output Area
Editor Options
About the Output Window
Various Tabs
Right-click Menu
About the Results Grids
Toggle Fullscreen Editor
Open and Save Files
Change Current Schema
Find text in the Editor
Create a Find and Replace Macro
Use Bookmarks
Find in Files
Move Between Editor Tabs
Automatically Back Up the Editor
Use an External Editor
28
28
29
29
29
29
29
29
29
29
30
30
30
30
30
30
31
31
31
31
32
32
32
33
33
34
35
39
39
40
40
40
Schema Browser Basics
About the Schema Browser
Schema Browser Panes
Customize the Schema Browser
View Schema Browser Icon Legend
Automatically Refresh the Schema Browser Data Grid
Create Schema Browser Filters
Create Default Schema Browser Filters
Apply Saved Schema Browser Filters
Quickly Filter the Schema Browser Left-Hand Side
Filter Data in the Schema Browser
Clear Schema Browser Filters
42
42
42
43
43
44
44
44
45
45
46
46
Toad 12.11 Getting Started
Contents
4
Data Grid Basics
About Data Grids
Anchor Column in Data Grid
Hide Columns
Understand Time Values
Sort and Group Data
Search Grids
Incremental Searching
Filter Data
Preview Selected Column
Include Row Numbers and ROWID
Copy Column Names to the Clipboard
47
47
48
48
48
49
49
49
50
50
50
51
Work with Data
Understand Editable Resultsets
Copy Data to Another Schema
Compare Data
Compare Data Duplicates
Insert and Delete Rows
Post/Revert Edited Data
Edit Data in Popup Editor
Perform Calculations on Grid Cells
Use the Calculator
52
52
52
53
56
56
57
57
57
57
Work with Database Objects
Describe Objects
Object Search
Search Term
Object Status
Specifying your Search
Schemas to Search
Search Object Names
Search Column Names
Source Search
Copy Objects to Another Schema
Create or Alter Objects
Use Existing Object as Template for New Objects
Drop (Delete) Objects
Flashback Tables (Recover Dropped Tables)
View Parent/Child Datasets in the Schema Browser
Create, View and Modify Object Privileges
Configure Grantees
Look Up Foreign Keys
The Foreign Key Lookup Window
Compare Objects
59
59
60
60
60
60
60
61
61
61
61
61
62
63
63
63
64
64
65
65
66
Toad 12.11 Getting Started
Contents
5
Compare Individual Objects
Compare and Synchronize Multiple Tables
Compare Schemas
Compare and Synchronize Schemas
Compare Multiple Schemas
Compare Databases
Rebuild Objects
About Rebuilding Objects
Rebuild a Table
Rebuild an Index
Rebuild Multiple Objects
66
67
70
73
73
75
77
77
77
78
78
Work with Code
Write Statements and Scripts
Move through Code with the Navigator
Pick Objects from the Object Palette
Use Code Completion Templates
Create Templates for Make Code Statement Functions
Examples:
Create and Manage Code Snippets
Complete Code from a Pick List
Use Query Templates
Format Code
Highlight Statements
Fold Code Segments
Change Text to Upper or Lower Case
Swap with Previous Line
View and Merge Differences
View Differences
Merge the Code
Examples
Preview Query Results
Save Query Results
Copy Statements between Toad and Development Tools
Strip Code Statement
Make Code Statement
How to Select the Code Development Tool
View Code Statistics
Work with the Query Builder
Query Builder Overview
How to use the Model Area
Build a Query
Create a Subquery
Populate the Where Clause
Use a Generated Query
Generate ANSI Syntax
81
81
81
82
83
84
84
85
86
86
87
88
89
89
89
90
90
91
91
92
92
92
93
93
93
94
94
94
95
96
96
97
99
100
Toad 12.11 Getting Started
Contents
6
Tune the query
Save Query Results
Execute Statements and Scripts
About Executing Scripts
Execute Single Statements
Execute Scripts in the Editor
Execute long-running scripts
Execute scripts with the @ command
Execute SQL with SQL*Plus
Save Statements (SQL Recall)
Save and Reuse SQL Statements
Execute a saved SQL statement
Export or import a saved SQL statement
Import/Export Saved SQL
Work with PL/SQL Objects
Load Database Object
Reload Object
Create New PL/SQL Object
Default Templates
Custom Templates
Keyword substitutions in templates
Extract Procedures
Generate DBMS Output
Execute SQL Statements within PL/SQL
Execute PL/SQL
Debug
About Debugging
Types of Debugging
Compile with Debug Information
Compile without Debug Information
Get more information on Debugging
Debug PL/SQL
Minimum Oracle Requirements for Debugging
Start Debugging
Set Parameters
Set Parameters in Triggers
Handle Dependencies and References
Display PL/SQL as it is Called
Stop the Debugger
Prepare PL/SQL Code for Production
View Debugging Results
Use DBMS Output
Create and Run Unit Tests
Debug Scripts
Script Debugger Overview
100
100
101
101
102
102
102
103
103
104
104
105
105
105
106
106
107
107
108
108
108
109
109
110
110
110
110
111
111
111
112
112
112
112
113
115
116
116
117
117
117
118
119
120
120
Toad 12.11 Getting Started
Contents
7
View Script Output
Set Breakpoints
About Breakpoints
Set a Breakpoint
Set Watches
About Watches
Add a Watch
Use Smart Watches
Analyze Code
About Code Analysis
Rules and Rule Sets
Code Analysis Metrics
Get more information
Analyze Code in the Editor
Optimize SQL
Optimization
Profile PL/SQL
About the Profilers
Hierarchical Profiler
Set Up the Profiler
Use a PL/SQL Profiler
View Profiler Results
Editor Profiler Tab
Generate Explain Plans
Generate Explain Plans
Save Explain Plans
121
121
121
121
122
122
122
123
124
124
124
124
125
125
126
126
127
127
127
128
128
129
130
131
131
131
Customize the Toad Interface
Customize Connections
Color Code the User Interface per Connection
Organize Database Connections
Display Only Favorite Connections
Add Custom Columns
Group Connections (Create Tree View)
Hide/Display Columns
Display Only Connections for Selected Oracle Home
Display Tabs for Each Server or User
Customize Workspaces
About Workspaces
Use Custom Workspaces
Use Shortcut Keys
Customize Shortcut Keys
Print a List of Shortcut Keys
Customize Toolbars, Menus and Commands
Enable Self-Configuring Menus
Show/Hide Toolbars
133
133
133
133
134
134
134
134
135
135
135
135
135
136
136
137
137
137
137
Toad 12.11 Getting Started
Contents
8
Rename Toolbars, Menus or Commands
Create New Toolbars, Menus and Commands
Add, Reorder and Remove Commands
Show Additional Menus
Delete a Menu
Reset Default Toolbars and Menus
Lock Toolbars
Effect of Upgrades on Customizations
Customize the Editor
Customize the Editor Layout
Use Bookmarks
Auto Replace Substitutions
Customize the Schema Browser
Select the Left-Hand Side Display Style
Customize Schema Browser Tabs
Group Favorite Objects
Customize Schema Drop-Downs
138
138
138
139
139
139
140
140
141
141
142
142
143
143
144
145
146
Use other Quest Products with Toad
Link to Toad Intelligence Central from Toad
Integrate Toad with Code Tester for Oracle®
Launch Quest SQL Optimizer for Oracle
Test in Benchmark Factory™ for Databases
Use Spotlight Essentials
147
147
148
149
149
150
About us
Contacting Quest
Technical support resources
152
152
152
Toad 12.11 Getting Started
Contents
9
1
Welcome to Toad™ for Oracle®
Version 12.11
Toad for Oracle provides an intuitive and efficient way for database professionals of all skill and experience
levels to perform their jobs with an overall improvement in workflow effectiveness and productivity. With Toad for
Oracle you can:
l
Understand your database environment through visual representations
l
Meet deadlines easily through automation and smooth workflows
l
Perform essential development and administration tasks from a single tool
l
l
l
Deploy high-quality applications that meet user requirements; perform predictably and reliably in
production
Validate database code to ensure the best-possible performance and adherence to bestpractice standards
Manage and share projects, templates, scripts, and more with ease
The Toad for Oracle solutions are built for you, by you. Over 15 years of development and feedback from various
communities like Toad World have made it the most powerful and functional tool available. With an installedbase of over two million, Toad for Oracle continues to be one of the most preferred tools for database
development and administration.
It is important to note that Toad for Oracle will only let you do what your DBA has granted you the rights to do via
direct privilege grants or indirectly through roles. Toad does not circumvent, augment or otherwise defy your
Oracle database security settings. If the DBA does not grant you the CREATE TABLE privilege, then the Create
Table in Toad will not work. Likewise If the DBA does not grant you the CREATE PROCEDURE privilege, then
the PL/SQL Editor in Toad will be severely limited. You will not be able to compile procedures, functions or
packages. Toad only allows you to do what your DBA has permitted you to do.
Toad 12.11 Getting Started
Welcome to Toad™ for Oracle®
10
About This Guide
The goal of this guide is to help you start using Toad quickly by learning basic features and tasks. Toad is a very
diverse and powerful tool, and there are many features not covered here. In many cases, a feature may be
introduced in this guide, with further instructions to see the online help. Refer to the online help for thorough
documentation on all Toad functionality. You can access the help at any time by pressing F1. You can:
l
Use the Table of Contents to get an outline view of all the components of Toad and links to the related
documentation. You can also go directly to this page by clicking Help | Contents.
l
Use the Search tool to find topics based on keywords that you input.
l
Use the Favorites tab to bookmark topics to which you refer frequently.
Toad 12.11 Getting Started
Welcome to Toad™ for Oracle®
11
2
Toad Resources
Toad provides a wealth of internal and external resources to support you in your work. These resources can
help you work more quickly, collaborate across locations, and more.
Jump Search
Use the Jump Search feature to find almost any Toad feature or functionality. You simply type in one or more
keywords, or the name of a Toad feature, and Toad shows it to you – right there in the interface. You can also
link to Jump Search solutions by clicking any error that is returned when you run your code in the Editor.
Jump Search also shows links to internal help topics and relevant Knowledge Base articles. In addition, it shows
links to external resources that provide a wealth of information and how-to videos about Toad from various
online sources.
To use Jump Search
By default, the Jump Search field is located to the far right side of the main toolbar.
The following example shows some of the ways to use Jump Search:
l
Type "code snippets" in the Jump Search field on the main toolbar.
l
Under Menus and Toolbars, double-click View > Code Snippets. You are taken to that menu item.
l
Click the Toad World header to expand results in the list for the user forum, knowledge articles, blog
posts, and how-to videos.
l
Double-click the Search Web header to open your default browser.
l
Double-click a link under Knowledge Base to open the target article in Toad.
Toad also jumps from error dialogs to the Jump search where the error message is then copied so you can
quickly find answers.
How Jump search functions
Toad 12.11 Getting Started
Toad Resources
12
Jump search results reflect licensing.
For instance, 'Health Check' will not appear in search results if
you have a Standard license.
And because Code Analysis Rules require the Professional
Edition, that category will not appear if you do not have that
edition of Toad.
Jump search results reflect Toad
security.
Clicking on a search result, such as Editor > Save File, applies
the same inherent limitations you would experience in your
instance of Toad.
Items searched (if available with your license)
Windows and most controls on all major
windows
These search results, or Targets, are contained in a file in the
user application data directory named "JumpTargets.dat."
Caveats:
l
l
l
If the Target is on a connection-bound window and no
connection is present you'll be informed.
If the Target is on, say, Step 3 of a wizard pane, it will
take you to the control on step 3, even if this means the
window is not in a useable state.
The error will indicate "Item not available in current
window state."
The "as you type" facility uses a priority-based search
algorithm which examines the various components of
the Target display string: the window, the path to the
Target, and the destination Target itself, and gives
priority first to the control, next to the window and then
to the path.
Toad Options
Note: You can also go to View | Toad Options and use the
Search field at the bottom of that window to limit your search to
Toad Options.
Menus and Toolbars
All menu items and main form toolbar buttons.
If you have customized your toolbars, and you removed an
item for which you are searching, it will open the toolbar
customization dialog to let you know that item is no longer
there.
Files
SQL Recall
A variety of file paths are included in the set Toad searches.
Among them are:
l
All Toad installation and application directories
l
All Toad MRU files
l
All filenames embedded in Actions
All the items of SQL Recall History are searched.
Toad 12.11 Getting Started
Toad Resources
13
Code Analysis Rules
All of the following fields are searched: RuleID, Category,
Type, Severity, and description.
Toad World User Forums
The new Toad World User Forums are searched and links are
provided to blog posts, forum questions and answers, and
how-to videos, which display directly within Toad.
Help Documentation
Similar to the previous Quick Search, results are provided from
Knowledge Base articles and other resources.
Search Web
Double-clicking this link loads your search string into your
default Web browser. To specify the search engine to use, go
to View | Toad Options | Online | Jump Search, and then
select a name under Jump Search.
Knowledge Base
Links to the Toad Knowledge Base articles that match your
search term are displayed. Double-click any link to show the
article within Toad.
Product Page and Videos
Links to the Toad page on the support site and links to videos
about Toad.
Toad Advisor
Toad is self-diagnosing. If you are having difficulties with Toad that you cannot understand nor fix, the Toad
Advisor may be able to help you. It offers warnings, alerts, and hints concerning the current state of your Toad
installation. If you are in a managed environment, it specifies which features in Toad are managed, and to
what extent.
To use Toad Advisor
1. Select Help | Toad Advisor.
2. Review the results, which are divided into the following categories:
Warnings
Describe things that should be fixed immediately
Alerts
Describe things that may have an impact upon Toad's functionality
Hints
Provide information about your Toad installation that may affect how Toad
works
Performance
suggestions
Describe settings that could be changed to improve speed of performance
Tip: Select a result for additional information in the bottom pane. You can double click the
performance suggestions to navigate direction to the relevant Toad option.
Toad 12.11 Getting Started
Toad Resources
14
Toad World
The parent site for all Toad family products is ToadWorld.com, where you will find videos, white papers, expert
blogs and podcasts, as well as beta releases, trial downloads and much more.
The Search bar on this website not only finds items that match your search criteria, it also groups them by
category, such as Ideas, Blogs, Forums, and so forth.
Two of the most-often used features of Toad World are the Forums and the Idea Pond.
Idea Pond
On the Idea Pond page of Toad World, you can submit your ideas to improve Toad and vote for or against other
customers' ideas. The Toad team takes your suggestions seriously, and you may even hear back from one of
our developers on the topic. We encourage all Toad users from new to experienced to let us know how we can
improve Toad.
To submit an idea
1. Log into Toad World at http://www.toadworld.com/products/toad-for-oracle/i.
2. Click Submit New Idea, then select a category.
3. Complete the information, then click Save.
To vote on an issue
In the list of ideas or within the idea itself, click the up arrow to vote for the issue or click the down arrow to vote
against it.
Toad World Forums
You can access the Toad World forums directly from Toad in one of these ways:
l
Click an action from the Toad World menu on the main toolbar (next to Jump Search by default):
l
Select Help | Toad World.
From here you have access to the following:
l
l
Forums: Opens all forums in a single pane.
Ask Question or Start Discussion: Opens a new forum thread, where you can create and post your
question or discussion topic.
l
Sign In or Register. This feature uses single sign-on (SSO).
l
Forgot Password: Get help with your password.
Note: If you don't see these options, right-click on the mail toolbar and select Restore defaults.
Toad 12.11 Getting Started
Toad Resources
15
Tips for using the forums in Toad
l
l
l
When the viewing area is open (by clicking a forum post within Toad), CTRL+R brings up the comment
area; CTRL+Enter posts the comment; ESC closes the comment area if open, or closes the entire viewer
if the comment area is not open .
You can add attachments to your posts online and within Toad.
You can reply to an individual post or to the entire thread. Answers percolate to the top of the thread to
make it easier to find answers to questions.
l
Select Suggested Answer if you are not positive your answer is correct.
l
Use the tabs to filter and organize the threads.
Tips for using the forums on Toad World
l
l
l
l
l
You can subscribe to the forum or follow only your own questions/discussions, and those to which
you respond.
Select Use rich formatting to format your reply or question and add the ability to include an attachment
or embed content.
To receive emails that follow all posts, go navigate to | Forums | Email Subscribe to Forum.
To receive emails that follow a specific thread when you reply to a post or start your own, open the
thread then select Email Subscribe to Replies.
You can select Stop receiving emails on this thread in the emails you receive.
Toad Web-based Training
Make the most out of your investment by expanding your knowledge of the Toad product line. Web-based
training is a perfect accompaniment to your product license. This training walks you through major product
features and explains how to perform frequent tasks. You will also see how to utilize time-saving automation
functionality.
These self-paced, web-based training courses are available for free to all Toad World registered users. You will
receive a certificate of completion for each course once you pass the accompanying test.
Note: Make certain the view the System Requirements on the landing page to ensure that your system can run
the courses properly.
To register for Toad world
Go to http://www.toadworld.com, then click Register.
To go to the training
Go to http://www.toadworld.com/training/p/web-based-training. Make certain to log in with your Toad World
credentials.
Retrieve License Keys
Quest provides a web site to retrieve lost license keys. You must provide the email address associated with the
license and your license number.
Toad 12.11 Getting Started
Toad Resources
16
To retrieve your license key
1. Select Help | Licensing.
2. Click Retrieve License Key.
3. Complete the fields on the web site
Create Support Bundles
The support bundle window provides information about several aspects of your Oracle and Toad setups.
In addition, the Support Bundle lets you easily report problems to our peer-to-peer mailing lists or
directly to Support.
If Toad itself fails, the Error dialog box displays. This type of an error creates a log, saved as toad.elf. This
Eureka LogFile (.elf) contains both the application information and the callstack of the error created, and can be
very helpful to Support in solving issues you are having with Toad.
To create a support bundle
1. Select Help | Support Bundle.
2. Review the following for additional information:
Email Quest Support
This opens the "Email Quest Support" window with instructions and links
to contact Support, and to open a new case or service request.
Quest Web Support
This opens Quest Software's award-winning Support portal in your default
browser , with access to Licensing Assistance, the searchable Knowledge
Base, product downloads and more.
Attach TOAD.INI (or
SQL Tuning Support
details) to emails
If selected, this attaches the details to any email sent through the support
bundle, whether it is to the peer-to-peer Toad list or to Support.
Toad 12.11 Getting Started
Toad Resources
17
3
Required Privileges for Toad
To use Toad, certain privileges are required both in an Oracle database and in your Windows environment.
Required Oracle Privileges
Some Toad features require special Oracle privileges. This topic lists required privileges per Toad Edition.
Base Edition
Window
Privileges
Audit
SQL/Sys
Privs
To audit occurrences of a SQL statement, you must have the AUDIT SYSTEM privilege.
Current
Schema
Toolbar
ALTER SESSION system privilege.
DBMS
Debugger
For Oracle 10g and 11g, DEBUG CONNECT SESSION privilege.
To audit operations on a schema object, the object you choose for auditing must be in your
own schema or you must have AUDIT ANY system privilege. In addition, if the object you
choose for auditing is a directory object, even if you created it, then you must have AUDIT
ANY system privilege.
DB Admin Module
Window
Privileges
Alert Log
Viewer
The user account must have the EXECUTE privilege on Oracle's UTL_File package. (The
SYS schema has this privilege by default.)
Toad 12.11 Getting Started
Required Privileges for Toad
18
Window
Privileges
Analyze
All Objects
SELECT privileges on the CHAINED_ROWS table to view chained rows.
DBMS_
Flashback
EXECUTE privileges for DBMS_FLASHBACK.
Index
Monitoring
To see another user’s indexes you must have access to the SYS.OB$, SYS.IND$,
SYS.USERS$ and SYS.OBJECT_USAGE views and the ALTER ANY INDEX privilege.
Instance
Manager
SYSDBA or SYSOPER privileges to shut down or alter the status of a database.
LogMiner
EXECUTE privileges on DBMS_LOGMNR and DBMS_LOGMNR_D.
Toad
Space
Manager
The Toad schema must have the privileges to create and alter jobs, create and drop its own
tables and procedures, and must have SELECT access on: DBA_TABLESPACES, DBA_
DATA_FILES, DBA_FREE_SPACE, and V_$FILESTAT.
Windows Privileges and Toad
In order to install and run Toad for Oracle, make a connection, and do basic operations, you must have the
following privileges:
Operating System
Requirements
Windows XP
l
Windows Server
l
Read access to the Oracle client folder
Read/write privileges on the Oracle Homes directories that you
use for your connections
l
Be a Power User or Administrator
Windows Vista
l
Read access to the Oracle client folder
Windows 7
l
l
Windows 8
l
Windows Server 2012
l
Read/write privileges on the Oracle Homes directories that you
use for your connections
If UAC (user account control) is enabled, you must have
administrator privileges
Read access to the Oracle client folder
Read/write privileges on the Oracle Homes directories that you
use for your connections
Note: Other functionality in Toad may require additional privileges.
Toad 12.11 Getting Started
Required Privileges for Toad
19
4
Create and Manage Database
Connections
Toad can connect to one or more databases. You can create, store, change, and organize these connections all
from one convenient location.
About Database Connections
You create, store, view, and edit database connections from the Database Login window.
To open the Database Login window
From the main Toad menu, select Session | New Connection.
To connect to a database server (referred to simply as database), Toad requires that you have the following:
l
l
l
A database client (referred to as client) installed on your computer. A client location is also referred to as
an Oracle home. You can have multiple Oracle clients installed on your computer. You select which one
Toad uses when you create a connection. Oracle recommends that your client version be of the same
release (or later) as your database server to prevent performance issues. See the Toad for Oracle
Release Notes for a complete list of the client and database versions that Toad supports.
Valid login user names and passwords to the databases that you will be working with from Toad. Toad
honors the user security assignments, so you must have the proper permissions required to perform any
given action in Toad.
Connection details and files that are required for the connection type that Toad will use to connect to
the database.
The Oracle client installation generally includes connection configuration files that are used to facilitate
communication between your computer and the database. Toad uses the following connection configuration
files, depending on the connection type you select.
Oracle connection files
Toad 12.11 Getting Started
Create and Manage Database Connections
20
Connection
File
Description
SQLNET.ora
Specifies configuration details for Oracle's networking software, such as trace levels,
the default domain, session characteristics, and the connection methods that can be
used to connect to a database (for example, LDAP and TNSNAMES). If a method is not
listed, you cannot use it.
Toad uses the SQLNET.ora file for all connection methods, and consequently you must
be able to access this file for any connection method.
TNSNames.ora
Defines database address aliases to establish connections to them. Toad must be able
to access the TNSNames.ora file for TNS connections.
IFILE
Toad supports the IFILE directive within TNS Names files. The IFILE directive allows
you to link to an external TNS Names file and dynamically include its contents along
with the contents of your local TNS Names list. You can include TNS files up to three
levels deep in order to organize and manage TNS entries within your company.
You can open an IFILE reference by right-clicking the reference and then selecting
Open in Other Editor.
LDAP.ora
Defines directory access information using Lightweight Directory Access Protocol
(LDAP). Toad must be able to access the LDAP.ora file for LDAP connections.
Create or Edit a Connection
Use the Database Login window to create and edit database connections.
Note: Toad does allow you to enter the connection information directly in the Database Login window, but this
method forces you to connect to the database, and you cannot enter some of the additional connection
information until after you connect.
To connect to an Oracle Cloud Database, see the online help. You must set it up so you connect from Toad to
the cloud database by establishing an SSH tunnel and then directing the Toad connection through the tunnel.
To create or edit a connection
1. Click
in the standard toolbar to open the Database Login window.
You can also select Session | New Connection.
2. On the Database Login toolbar, click
(Create New Connection) to create a connection, or select a
connection then click
(Edit Login Record) to edit an existing record. The Add Login Record or Edit
Login Record window is shown.
3. Complete the User/Schema and Password fields.
4. Select a connection method:
TNS
Select a database in the Database field. Toad uses the listings in your
Toad 12.11 Getting Started
Create and Manage Database Connections
21
TNSNames.ora file to populate the list. You must use TNS when connecting to
an Oracle Cloud database.
Direct
Enter the Host, Port, and either the Service Name or SID of the database to
which you want to connect.
You must use Service Name rather than SID to connect to an Oracle 12c
Pluggable database.
LDAP
Select the LDAP descriptor in the LDAP Descriptor field.
Notes:
l
Toad must be able to access the SQLNET.ora file to use any of the connection methods.
l
Toad must be able to access the LDAP.ora file for LDAP connections.
l
Toad must be able to access the TNSNames.ora file for TNS connections.
If Toad cannot connect to one of these files, a red X displays beside the editor button for that file. For
example, the following image indicates that Toad cannot access the LDAP.ora file. You would have
to resolve the issue before you could make an LDAP connection.
Toad 12.11 Getting Started
Create and Manage Database Connections
22
5. Complete the remaining fields as necessary.
Connect as
Select the connection privilege level field.
Color
You can use connection colors to help you distinguish between open connections.
Color Code the User Interface per Connection
Connect
Using
Select the Oracle home.
Default Oracle homes can be assigned for a connection or for Toad. When a default
Oracle home is assigned to a particular connection, any time you make that
connection from the connection grid, Toad automatically uses that Oracle home.
When a default Oracle home is assigned to Toad, Toad automatically uses that
Oracle home any time you create a connection to a new database.
See Select a default Oracle Home in the online help for more information about how
Toad manages Oracle homes.
Alias
Enter a description or Toad based alias or nickname for the connection.
By default the alias only displays in the connections grid, but you can have Toad
display the alias instead of the database name. To enable this option, select View |
Toad Options | Windows and select the Use alias instead of database checkbox.
Execute
Action
upon
Connection
An Action in the Automation Designer can be automatically executed upon making
a connection:
a. Highlight the connection and click Edit Login Record.
b. Select Execute Action upon Connection and specify the Action. The Action
displays in the Action field of the connection window. You can also select a
parameter file.
See Automation Designer Overview in the online help for more information about
how to automate frequently used tasks.
Notes: Toad only executes actions upon connection when you execute through the
user interface. Toad does not execute actions when it is executed through
command line.
Custom
Columns
Complete the custom fields, if you have defined any.
Save
Password
Select to have Toad remember the password for only this connection.
Organize Database Connections
Note: If Save passwords is selected in the Database Login window (to save
passwords for all current and future connections), then this field is selected by
default.
Save Connection Passwords
Auto
Connect
Select to have Toad automatically make the selected connection on startup.
Favorite
Select this checkbox to mark the connection as one of your favorites. You can have
Toad 12.11 Getting Started
Create and Manage Database Connections
23
the Database Login window only display your favorites by selecting Show favorites
only at the bottom of the window.
Read Only
Select this checkbox to make the connection read only, meaning that you cannot
make any changes to the database. This option is especially helpful when you want
to access data for a production database but you do not want to accidentally make
any changes.
6. Save the login record.
l
To save the record without connecting to the database, click OK
l
To save the record and connect to the database, select the Connect checkbox and click OK.
l
To save the record and reuse the field values to quickly enter new connections, click Post.
Save Connection Passwords
You can have Toad save all passwords automatically or individually save passwords for selected connections.
Passwords are saved in an encrypted file named Connections.xml. The encryption is tied to the currently
logged in user profile, and it supports roaming profiles and Citrix installations.
Important: To save a connection password, you must connect to the database first.
Note: If the Save Password field is disabled, your ability to save passwords may have been removed during
installation. See the Toad for Oracle Installation Guide for more information.
To save all passwords automatically
1. Click
in the standard toolbar to open the Database Login window.
You can also select Session | New Connection.
2. Select Save passwords at the bottom of the window. All passwords for current and future connections
will be saved automatically.
To save passwords for individual connections
1. Click
in the standard toolbar to open the Database Login window.
You can also select Session | New Connection.
2. Clear Save passwords at the bottom of the window.
3. Select the connection in the connection grid.
Note: If the connection is not listed in the connection grid, ensure that the Show favorites only and
Show selected home only fields are cleared. If it still does not display, connect to the database again.
4. Click
to open the Edit Login Record window
5. Enter the password in the Password field on the right.
6. Select Save Password.
7. Click Connect.
Toad 12.11 Getting Started
Create and Manage Database Connections
24
Import/Export Connection Settings
You can export and import Toad connection settings. This feature is especially helpful when you need to work
with Toad on a different computer or share the settings with another person. If you save your connection
password, it is encrypted in the exported file.
To export connection settings
1. Click
in the standard toolbar to open the Database Login window.
You can also select Session | New Connection.
2. Click
on the toolbar.
3. Enter a file name in the File Name field and click Save.
To import connection settings
1. Click
on the toolbar.
2. Select the connection settings file and click Open.
To import from LDAP
l
In the Database Browser, click the folder icon.
l
Select Add databases to tree.
The Database Browser displays columns for Server, Database, Comments, and Last Connected.
Automatically Connect on Startup
Rather than have to manually connect to one or more databases every time you start Toad, you can configure
Toad to start selected (or all) connections automatically when you start Toad.
To automatically open connections
1. Click
in the standard toolbar to open the Database Login window.
You can also select Session | New Connection.
2. In the connections grid, select the checkbox in the Auto Connect column.
Use Previous Connections
Toad saves your previous connections so you can easily connect to them again.
To open a previous connection
Select one of the following:
Toad 12.11 Getting Started
Create and Manage Database Connections
25
l
l
Click
in the standard toolbar to open the Database Login window, and then doubleclick the previous connection from the grid.
Click the arrow beside
from the list.
in the standard toolbar, and then select a connection
Change Active Connection in Window
You can easily change the connection in an open window to a connection you currently have open or a
connection that you have recently used.
To change the active connection in a window
Click the arrow beside
in the window toolbar and select an open or recent connection from the drop-down.
Test Connections
To test connections if the session has dropped
Select Session | Test Connections (Reconnect)
or
Session | Test All Connections (Reconnect)
To test connections in the Database Login window
Select connections in the grid and click
errors that occur.
. Toad opens a new session to test the connection and lists any
End Connections
Toad provides a number of ways to end a database connection.
To end one connection
Select Session | End Connection.
Or
Click
in the standard toolbar to end the currently active session. You can also click the arrow by the button to
select a different open connection to end.
Or
Right-click the connection name in the toolbar, then select End Connection.
To end all connections
Select Session | End All Connections.
Toad 12.11 Getting Started
Create and Manage Database Connections
26
Commit or Rollback Changes
You can commit or rollback recent changes to the database from the Session menu at any time while working
with Toad.
Note: You can configure Toad to either automatically commit changes or prompt to commit on exit. See "Oracle
Transaction Options" in the online help for more information.
To commit or rollback your changes
Select Session | Commit or Session | Rollback.
Tip: You can also right-click the connection in the Connection Bar, and select Commit
or Rollback. You can also commit or rollback a session from Session | Transaction in
the main menu.
Toad 12.11 Getting Started
Create and Manage Database Connections
27
5
Editor Basics
The Toad Editor lets you write and edit many types of statements and code, and Toad provides many options to
customize the Editor's behavior. You should get to know the Editor well, because it supports most of the core
functionality of Toad, and much of your work will be done there.
About the Editor
The Editor window is the foundation for working with many types of statements and code. The Editor attaches
itself to the active connection in Toad, but if you do not have a connection you can still use it as a text editor.
This topic describes the basic Editor components. As you use other features in Toad or if you customize the
Editor layout, the appearance of the Editor will change.
Editor Toolbars
The Editor has the following default toolbars. Hover your mouse over a button to determine its functionality. You
can show or hide toolbars and buttons to customize your work area. Show/Hide Toolbars
File
The main Editor toolbar that contains functionality for changing sessions, opening and saving files, printing,
launching external software related to Toad, creating new PL/SQL objects, and launching the SQL Recall tool
for saving and viewing statements.
Edit
Contains basic editing tools for writing and formatting code.
Execute
Contains buttons related to compiling or executing code.
Toad 12.11 Getting Started
Editor Basics
28
Current Schema
Shows the currently connected schema and enables you to change the schema to execute the code against.
Change Current Schema
Desktop
Shows the current desktop layout and enables toggling between SQL and PL/SQL desktops.
The SQL desktop is mainly for working with scripts, while the PL/SQL desktop is for working with procedures,
functions and packages.
The desktop determines what tabs are displayed in the Editor:
l
The SQL Desktop shows the Data Grid, Trace, Query Viewer, Explain Plan, and Script Output tabs.
l
The PL/SQL Desktop shows the Call Stack, Breakpoints, Watches, Profiler, and PL/SQL Results tabs.
l
Both show the DBMS Output, Messages, and Team Coding tabs.
Macro
Contains buttons for creating and running macros. See Editor Macros for more information.
Code Analysis
Contains buttons for running Code Analysis. About Code Analysis
Team Coding
Contains buttons that support the Team Coding feature.
See About Team Coding in the online help for more information.
Intelligence Central
Contains buttons for connecting to a Toad Intelligence Central server to download or upload supported artifacts.
Link to Toad Intelligence Central from Toad
Editor Layout
The Editor is organized into the following areas:
Navigator Panel
The Navigator Panel is a desktop panel that displays an outline of the Editor contents in the active tab. You can
click on the items listed to navigate to that statement in the Editor. The Navigator Panel is displayed on the lefthand side by default, but you can change where it is docked.
If the Navigator is not shown, right-click the Editor and select Desktop | Navigator.
Move through Code with the Navigator
Toad 12.11 Getting Started
Editor Basics
29
Object Palette
The Object Palette shows a list of the database objects that are in the currently selected schema.
Pick Objects from the Object Palette
Editor
The main Editor window displays code in tabs. You can open new tabs for different bits of code, or different
types of code. SQL and PL/SQL can go in the same tab. Toad can tell where the cursor is located and compile
PL/SQL or run SQL as required.
Note: If you have multiple statements in the Editor, you must trail them with a valid statement terminator such as
a semi-colon.
Desktop Panels
The desktop panels contain many options for tab display, depending on what kind of code you are working with
and what you want to do with it. In addition, you can configure how these panels display to make Toad work for
you. Customize the Editor Layout
Editor Right-click Menu
The right-click menu of the Editor contains many options to help you work with code. When you are trying to
figure out how to do something, right-click the Editor to see if there is a menu or command for it. For example,
right click a table and then select Describe to open the Describe Objects window. You can also select the
object, then press F4.
Shortcut Keys
Toad provides dozens of standard shortcut keys, plus you can assign new ones or customize the standard ones.
Toad also allows you to print out your current list of shortcut keys.
Customize Shortcut Keys
You can customize the shortcut keys. Customize Shortcut Keys
Editor Results Area
At the bottom of the Editor are tabs that display results of your actions with code.
Depending on your Toad Edition, any of these tabs display results:
l
Messages: Displays information based on the context of the work performed in the Editor.
l
Data Grid: About Data Grids
l
DBMS Output: Use DBMS Output
l
Script Output: View Script Output
l
Trace: See Auto Trace in the online help for more information.
Toad 12.11 Getting Started
Editor Basics
30
l
Query Viewer: See Query Viewer in the online help for more information.
l
Explain Plan: Generate Explain Plans
l
Breakpoints: About Breakpoints
l
Watches: About Watches
l
PL/SQL Results: View Debugging Results
l
Call Stack: Display PL/SQL as it is Called
l
Profiler: Editor Profiler Tab
l
Team Coding: See About Team Coding in the online help for more information.
Output Area
About the Output Window
Editor Options
You can customize the behavior of the Editor in many ways.
To set Editor options
1. Select View | Toad Options | Editor.
2. Select an options group and then press F1 for information about those options.
About the Output Window
The output window displays whenever there are results of an action. The Output window can be sized however
you want. By default it is docked at the bottom of your screen.
In addition, the output window displays error messages, and other general information Toad creates for you.
Output is sent to various tabs as needed. Using the popup menu you can work with the messages displayed in
the Output window.
Various Tabs
Output is sent to various tabs in this window as needed.
Tab
Contents
General tab
This tab provides general information.
<connection> tab
This tab provides information about what you have done during a connection.
For example, if you end or begin a Debugger session for a specific connection a
log of this will be displayed here.
Toad 12.11 Getting Started
Editor Basics
31
Tab
Contents
Spool SQL tab
This is where SQL is displayed from the Spool SQL command. This is the SQL
Toad uses to perform various functions.
Right-click Menu
From the right-click menu you can do several things.
Command
Result
Clear
Clears all messages in the active output tab.
View Messages
Displays the selected messages in a dialog box. This is useful when a message
is too long to view in the Output window, or contains linefeeds.
Copy
Copies the contents of the Output window to the clipboard.
Print
Prints the contents of the Output window.
Save to File
Saves the contents of the Output window to a text file.
Spool SQL to Screen
Toggles spooling.
About the Results Grids
At the bottom of the Editor are tabs that display results of your actions with code within the edit window.
Depending on your Toad Edition, any of these may display results:
l
Data Grid: About Data Grids
l
DBMS Output area: Generate DBMS Output
l
Script Output area: View Script Output
l
If you have the debugger module, you may also have the Script Debugger displayed.
Toggle Fullscreen Editor
You can expand the Editor to fill the entire screen, hiding all other desktop panes. The fullscreen Editor does not
affect windows such as the Object Palette or Code Snippets.
To toggle the Fullscreen Editor
Select Toggle Fullscreen Editor (F2) from the Edit menu.
Toad 12.11 Getting Started
Editor Basics
32
Open and Save Files
The default in Toad's Editor is the standard Windows-style Open and Save File dialogs.
To open a file
Click
(Open file) on the Editor toolbar.
To load an object from the database
Click
(Load Object from Database) on the Editor toolbar.
To save a file or files
Click one of the following:
disk location.
(Save),
(Save As),
(Save All Tabs). Files are saved to a selected
Change Current Schema
The Current Schema drop-down, located on the Current Schema toolbar, lets you work with a schema other
than the one to which you are connected. This can be useful if, for example, you have tested a SQL statement in
your test schema and now want to execute it on several other schemas without disconnecting and reconnecting.
Sample Current Schema Drop-down
By default, the current schema is set to your current connection. When you use this drop-down, Toad issues an
ALTER SESSION SET current_schema command. After you execute, Toad issues the ALTER SESSION SET
current_schema command again to return to the original connection schema.
Notes:
Toad 12.11 Getting Started
Editor Basics
33
o
You must have the ALTER SESSION system privilege to use this feature. If you do not have the privilege,
the drop-down is disabled.
o
Using this feature eliminates the need to prefix every table name with a schema name, and helps to
eliminate ORA-00942 “table not found” errors.
To change the current schema
Select a different schema from the Current Schema drop-down on the Current Schema Toolbar.
The Current Schema drop-down does not work with script execution or debugging commands. However,
because Execute as Script is designed to mimic SQL*Plus, you can use a set schema command to
change the schema.
To change the schema in scripts
Include the following command at the beginning of your script:
ALTER SESSION SET current_schema = "USERNAME"
Find text in the Editor
The Editor provides multiple ways to find what you are looking for in the Editor window.
All of these tools are located under the Search menu on the main Toad Toolbar.
To save the settings as a macro, click
in the dialog toolbar.
Command
Shortcut
Description/Actions
Find
CTRL+F
Opens the Find dialog.
Enter a keyword or phrase to search for in the Editor window.
There are options for case sensitive, finding whole words, using Regular
Expressions (see Regular Expression Searches), and searching forward or
backward in the buffer.
If text is highlighted prior to opening the Find dialog box, that text will be
placed into the Text to Find data entry box. If no text is highlighted, then the
word at the cursor will be placed in the Text to Find data entry box. The last n
find items are available in the drop-down list. They are NOT saved from Toad
session to Toad session.
You can also copy other text and paste it into the Find dialog box using
CTRL+V.
Find may be available for a window even if the Find button is not present on
the toolbar. In these cases, you easily can use CTRL+F from the keyboard to
access this feature.
Replace
CTRL+R
Opens the Replace dialog, where you can find the keyword or phrase, and
then replace it with a different string of text.
When you select Regular Expressions, you can use the Replace with
Template option to convert \t, \r, and \n in the text specified in Replace with to
a tab, carriage return, and newline, respectively.
Toad 12.11 Getting Started
Editor Basics
34
Command
Shortcut
Description/Actions
Show All
None
This command only works after you have performed the Find command. After
you use the Find command to search through your text for a word or phrase,
you can use Show All to highlight every occurrence of the search phrase. The
highlighting is removed with any change to the text in the Editor.
Find Next
F3
This item is only enabled after you have performed a Find. It goes to the next
occurrence of the text you were searching.
Find
Previous
SHIFT+F3
This item is only enabled after you have performed a Find. It goes to the
previous occurrence of the text you were searching.
Goto Line
CTRL+G
If you have a large file, you may want to use this command to move your
cursor to a specific line number.
You must enter an integer from 0 to the last line number of the buffer contents.
You can also use bookmarks to quickly navigate around the buffer contents.
Use Bookmarks
Find in
Files
None
Finds text in files and supports multiple concurrent searches. Find in Files
Create a Find and Replace Macro
Toad enables you to create Find-and-Replace Macros that enables you to quickly perform find-and-replace
tasks that you perform often.
To create a Find and Replace Macro
The following is an example of how to create a Find and Replace Macro. In this example, you frequently need to
select a few Product IDs from a large table and perform a query on them to make the data more manageable. To
accomplish this, you copy the IDs and paste them in the Editor. Then, you create two Find and Replace macros.
The first macro wraps the pasted IDs in quotes. The second macro removes newlines and converts them to a
comma separated list.
Toad 12.11 Getting Started
Editor Basics
35
1. Copy the Product IDs from the table, then paste them in the Editor.
Toad 12.11 Getting Started
Editor Basics
36
2. Create the first macro:
a. Click CTRL+R.
b. Complete the fields in the Replace window to wrap the IDs in quotes.
c. Click
and name the macro WrapInQuotes. Click OK.
d. Click Replace All in the Replace window. Toad runs the macro against the Editor.
Toad 12.11 Getting Started
Editor Basics
37
3. Create the second macro:
a. Click CTRL+R.
b. Complete the fields in the Replace window to create a comma separated list.
c. Click
and name the macro CommaSeparatedList. Click OK.
d. Click Replace All in the Replace window. Toad runs the macro against the Editor.
4. Use the new comma separated list to query the IDs.
Toad 12.11 Getting Started
Editor Basics
38
5. To reuse these macros in the future, click the down arrow next to the
(Replace Text) button in the
Edit toolbar. Run the WrapInQuotes macro first and then the CommaSeparatedList macro.
Use Bookmarks
Use bookmarks to help you manage files. They mark a position within the Editor so that you can easily jump
back to that line. You can set up to ten separate bookmarks within one Editor.
Note: All keystrokes assume you have not altered the default Editor keys.
To set a bookmark
Right-click and select Toggle Bookmark | Bookmark# (CTRL+SHIFT+# where # is a number between 0 and 9).
The bookmark number displays in the Editor gutter.
To clear all bookmarks
Right-click and select Clear All Bookmarks.
To clear one bookmark
Right-click and select Toggle Bookmark | Bookmark# (CTRL+SHIFT+# where # is a previously defined
bookmark between 0 and 9).
To jump back to a bookmark
Right-click and select Go to Bookmark (CTRL+# where # is a previously defined bookmark between 0 and 9).
Note: The # must be called from the number row on the keyboard. Using the Number pad will not
call the bookmark.
Find in Files
The Find in Files dialog supports multiple concurrent searches. When you select a result, a preview window
displays and stays on top so you can easily compare other results.
Note: This topic focuses on information that may be unfamiliar to you. It does not include all step and field
descriptions.
Toad 12.11 Getting Started
Editor Basics
39
To find in files
1. Select Search | Find in files.
2. Enter the text you want to find in the Search for field.
3. Enter the types of files you want to find in the File mask box. For example, *.* searches for all files and
*.txt searches for all text files. You can search for multiple file types and separate them with a semicolon,
such as *.sql;*.txt (searches for all .sql and .txt files).
4. Select options in the Find in Files toolbar to include additional search criteria, such as searching subfolders and using regular expressions.
5. Click
.
6. Double-click a file in the results to preview it. The preview window stays on top so you can easily
compare other results.
Move Between Editor Tabs
There are several ways to move between tabs in the Editor.
To move between tabs:
Do one of the following:
l
Click the tab you want to open.
l
Press ALT+PageUp or ALT+PageDown to cycle through them.
l
If you have opened them using the CTRL+Click functionality within the Editor, click the
navigation buttons in the Editor toolbar and select either scroll forward and back through
them in the order they were opened, or select from a drop-down order.
Automatically Back Up the Editor
You can have Toad automatically create backups of your Editor files using a temporary filename. If Toad closes
abnormally, you are prompted to recover or discard backups when you next open Toad. Auto backup is
automatically enabled, with a backup interval of every 3 minutes.
See Editor Behavior Options in the online help for more information.
You can also use this feature to recover documents manually.
To recover documents from the menu
Select File | Recover Documents.
Use an External Editor
You can use an external editor of your choice, and copy the text to the external editor, edit the text, and bring the
results back into Toad.
Toad 12.11 Getting Started
Editor Basics
40
To set up your External Editor
1. Select View | Toad Options | Executables.
2. Navigate to and select the executable for the external editor in the Editor field.
To open text in External Editor
Select Edit | Load in External Editor (CTRL+F12).
Note: If you have not saved the contents of the Toad Editor to a file, Toad prompts for a filename
before launching the external editor.
To return to Toad from the External Editor
1. Save the file from the external editor and then close it.
2. Open Toad and load the file.
Note: Toad prompts you to reload the contents of the file only if the Prompt for reload on activation if
timestamp has changed option is set in Toad Options.
See Editor Open/Save Options in the online help for more information.
Toad 12.11 Getting Started
Editor Basics
41
6
Schema Browser Basics
In Toad you use the Schema Browser to work with database objects.
About the Schema Browser
The Schema Browser allows you to view, add, and modify database objects. It also displays detailed information
about a selected object. For example, the detailed information for a table includes its subpartitions, columns,
indexes, data, grants, and so on.
Notes:
l
l
Some Schema Browser features may not be available unless you have the commercial version of Toad
with the DB Admin Module.
You can set the Schema Browser to open automatically when a new connection is made. Select View |
Toad Options | Windows and select the Auto Open checkbox of the Schema Browser row.
Schema Browser Panes
The Schema Browser is divided into two panes to help you review objects and their details:
Pane
Description
List of objects
(left-hand side)
The left-hand side of the Schema Browser is also known as the "LHS" (Left-Hand
Side) and is referred to as such throughout the documentation.
The LHS provides a list of objects that you can view. In general, you select a schema
and an object type, and the list refreshes to display the relevant objects. You can filter
the objects and save your filters for future use.
See About Schema Browser Filters in the online help for more information.
The list can display additional information about the objects, such as the tablespace
and number of rows. To view additional information, right-click a column in the lefthand side and select additional columns to display. (This feature is unavailable with
the tree view display.)
Toad 12.11 Getting Started
Schema Browser Basics
42
Pane
Description
Tip: In drop-down mode, you can hide leading characters of object names in the lefthand side. Right click a column and select Hide leading characters of name. The
display resets when you change the schema or connection.
Object details
(right-hand side)
The right-hand side of the Schema Browser is also known as the "RHS" (Right-Hand
Side) and is referred to as such throughout the documentation.
The RHS initially displays the same list of objects as the left-hand side. When you
select an object on the left-hand side, Toad displays its details in the right-hand side.
This format makes it easy for you to compare details between objects of the same
type.
From the Schema Browser you can drop most objects, enable/disable applicable
objects, and disable triggers for a table or for an entire schema. You can recompile
procedures, functions, packages, triggers, and views, or they can be extracted from
the database and loaded into the clipboard or Editor. If Team Coding is enabled, you
can view status and collection information.
Tips:
l
l
l
To reset the right-hand side to mirror the list of objects on the left-hand side, click
select multiple objects on the left-hand side.
in the toolbar or
Many of the panes within the Schema Browser have icons to identify the objects. View Schema
Browser Icon LegendView Schema Browser Icon Legend
Many of the objects and panes have enhanced right-click menus. Right-click an object or its details
to see what options are available.
Customize the Schema Browser
You can customize how the Schema Browser displays to better suit the way you work. The most common
customization is to change how object types display in the left-hand side. Select the Left-Hand Side
Display Style
Toad also provides dozens of options to further customize the display and behavior of the Schema Browser.
Select View | Toad Options | Schema Browser to view the options, then press F1 to view information
about them.
View Schema Browser Icon Legend
Many of the panes within the Schema Browser have icons to identify the objects. Toad includes an Icon Legend
that you can use to easily decipher these images.
To view the icon legend
Click
on the Schema Browser toolbar.
Toad 12.11 Getting Started
Schema Browser Basics
43
Automatically Refresh the Schema
Browser Data Grid
You can set the Schema Browser to automatically refresh the data grid while you are working with a specific
object. This setting only lasts for your active dataset, and turns itself off if you select another object or close the
Schema Browser.
To automatically refresh the data grid
Select Auto Refresh in the Data tab toolbar (right-hand side of the Schema Browser).
Create Schema Browser Filters
Object filters reduce the number of objects displayed in a schema. To create browser filters
1. Click
in the left-hand side. This displays the browser filter for the selected object type and schema.
2. Complete the fields as necessary.
3. To save the filter, click Saved Filters and select Save Current Filter As.
a. 'Save filter data for all object types,' or
b. 'Save filter data for roles only' (in this example).
Saves into an SBFLT file. When such a file is reloaded, current settings for other object types are
not changed.
4. To customize or review the query before applying it, select View/Edit Query Before Executing
and click OK.
Notes:
l
l
Do not change the SELECT list.
When entering the IN clause, you must enclose the table name in single quotes ('TEST'). This lets
you enter multiple table names ( such as 'TABLE1', 'TABLE2', 'TABLE3') or enter a sub-query.
Create Default Schema Browser Filters
You can create a default filter for each object type, which is used for all schemas.
Notes:
l
l
Instead of using the same default filter for each object type, you can have Toad automatically save filters
per connection or schema name. See Schema Browser Left-Hand Side Options in the online help for
more information.
This topic focuses on information that may be unfamiliar to you. It does not include all step and field
descriptions.
Toad 12.11 Getting Started
Schema Browser Basics
44
To create default filters
1. Select Session | Schema Browser Filters.
2. Select an object type on the left and set the filter options. Create Schema Browser Filters
Note: When you click OK, Toad saves default filters in a file named Toad_DEF.SBFLT in the User
Files folder.
Apply Saved Schema Browser Filters
To apply a saved filter
1. Click the arrow beside
and select a saved filter from the list.
2. If the filter you want is not listed, complete the following steps:
a. Click
in the left-hand side of the Schema Browser.
b. Click Saved Filters in the upper right of the dialog and select Load Filter
c. Select the filter and click Open.
d. Click OK to apply the filter and close the dialog.
Quickly Filter the Schema Browser
Left-Hand Side
The QuickFilter is a client-side filter, so it filters all Schema Browser object lists without re-querying the
database. This filter works in conjunction with the existing browser filters. () The QuickFilter provides a faster
way to filter the list than just using the browser filters.
The QuickFilter field is located below the schema drop-down for the tabbed and drop-down Schema Browser
display styles.
To use the QuickFilter
Enter the filter information. You can use wildcard characters at any point in your filter.
Wildcard
Description
* and %
Use for multiple character wildcards.
Note: % is the Oracle standard.
? and _
Use for single character wildcards.
Note: _ is the Oracle standard.
!
Use to exclude the following characters.
One exclamation point affects the entire string. For example,
Toad 12.11 Getting Started
Schema Browser Basics
45
Wildcard
Description
!A*;B* would return everything that does not start with A or B.
Notes:
l
l
You can use multiple filters by separating them with a semicolon. For example, A*;B*
would display everything that starts with A or B.
The QuickFilter maintains a history of up to 25 items, listed most recent first. Rightclick the QuickFilter to access this list.
Filter Data in the Schema Browser
The Schema Browser has the following methods to filter data:
l
Filter/Sort—This is a server-side filter that limits which rows are retrieved from the database. This method
is much faster than the grid filter when you are filtering a large dataset. Access this filter by clicking the
button in the tab's toolbar.
l
Filter Data—This is a client-side filter that retrieves all rows from the dataset before filtering them. Access
this filter by right-clicking the data grid.
To filter data in the Schema Browser
1. Click
in the tab's toolbar (right-hand side of the Schema Browser).
2. Complete the fields as necessary.
Clear Schema Browser Filters
To clear filters on the left-hand side
Click the arrow beside
and select Clear Filter.
o
'Clear Filter for <object type>,' or
o
'Clear Filter For All Object Types'
To clear data grid filters in the Schema Browser
Click
on the Schema Browser right-hand side.
Toad 12.11 Getting Started
Schema Browser Basics
46
7
Data Grid Basics
Throughout Toad, information is presented in a grid format. Within grids, you can customize grid views, filter
resultsets, print the grid contents, and other standard operations. If the data set is editable, Toad enables that to
be done within the grid.
About Data Grids
In most data grids you can:
Edit data:
l
Post/Revert Edited Data
l
Insert and Delete Rows
l
Edit Data in Popup Editor
l
Use an External Editor
l
Access the Calculator
Customize the data grid display:
l
Perform Calculations on Grid Cells
l
Anchor Column in Data Grid
l
View a Single Record
l
Preview Selected Column
l
Hide Columns
l
Sort and Group Data
Filter results:
l
Filter Data
l
Use Excel-Style Filtering
Export data:
Toad 12.11 Getting Started
Data Grid Basics
47
l
Export Dataset
l
Export Data to Flat File
View special data types:
l
Date Editor
l
View BFILE data
l
View CURSORs
l
View Nested Table Data
l
View Object Data
l
View VARRAY Data
Anchor Column in Data Grid
You can anchor a column on the left side of the data grid (also referred to as locking, fixing, or freezing the
column). This can make it easier to track information you must scroll through a large amount of content.
Note: Row numbers automatically display as fixed columns. With the exception of row numbers, fixed columns
remain editable.
To anchor a column
Right-click a column and select Fix Column.
To remove the column anchor
Drag the column to the right of the bold fixed column divider bar.
Hide Columns
You can hide columns from the data grid after running a query.
To select columns to display
1. Click
in the upper left corner of a data grid.
2. Clear the checkbox by the column name.
Tip: To sort the column list alphabetically, right-click the column list and select Sort Alphabetically.
Understand Time Values
When displaying times with dates, Toad suppresses the time values if they are 12:00:00 AM (midnight). The time
portion of the date fraction is zero, so Toad adds no value to the display of the date.
Oracle stores dates as a big fraction number offset from January 1, 4712 B.C. It is then converted to a complete
date and time.
Performing the query Select sysdate from dual will display the time, and similarly, queries of DATE datatype
columns will display the time if it is not midnight.
Toad 12.11 Getting Started
Data Grid Basics
48
The time drop-down in View | Toad Options | Data Grids does not affect this output of time.
Sort and Group Data
If the query does not contain an ORDER BY command, you can sort the grid manually.
To sort by column
1. Click a grid column header.
2. Select the appropriate option, and click Apply.
Search Grids
Use this dialog box to find data or columns in a grid. If the records are cached then the search is fast. If Toad has
to query ahead in the recordset, then you have to wait for the additional rows to be fetched from the database.
You can use this method to find data in one column, or in many, or items that match two or more criteria.
To find data or columns
1. Right-click the grid and select Find Data (CTRL+F).
2. Select the column to search or find.
l
l
To find a column, select Find Column and click OK. The data grid advances to the first
occurrence of the search criteria.
To find data, select Find Data and complete the search criteria. When you click OK, the data grid
advances to the first occurrence of the search criteria.
Note: To find the next occurrence of the search criteria, press F3.
l
To filter by data value, select Filter Data and then enter the search value. Note: Closing the
dialog will undo the filter, but the grid will remain on whatever row you filtered to.
3. Note: To find the next occurrence of the search criteria, press F3.
Incremental Searching
To find data incrementally
1. Click in the column you want to search.
2. Type the first few characters of the item you want to find.
3. Press F3 to continue stepping through the grid.
Toad 12.11 Getting Started
Data Grid Basics
49
Filter Data
Filters reduce the amount of data displayed and let you display only what you want to see. They work by
modifying the query used to fetch the data. If you frequently search for the same criteria, you can save the
filter for reuse.
To filter data
1. Right-click the data grid and select Filter Data.
2. To change the grouping clause, click AND to select a different option.
3. Click press the button to add a new condition.
4. To change the column, click the listed column and select a new one. The first column in the grid is
selected by default.
5. To change the condition, click equals and select the appropriate condition (LIKE, EQUAL TO, LESS
THAN, and so on).
6. Click <empty> and add your criteria.
7. To add additional conditions or groupings, click Filter and then select Add Condition or Add Group.
Preview Selected Column
You can display or hide a full row below each data row that shows the value of the selected column.
To preview current column
Right-click the column in the Data grid and select Preview Column.
Include Row Numbers and ROWID
Toad can display row numbers and ROWIDs in the Editor data grid.
The total number of rows returned in the resultset will display in the status bar at the bottom of the window only
after you have scrolled to the end of the resultset. This is because the resultset is fetched only as required, to
improve overall performance. When the last row is fetched, Toad will display the total count.
To display row numbers
Select View | Toad Options | Data Grids | Visualand then select Show row numbers (applies to data grid on
Browser also).
To return the Oracle pseudo-column ROWNUM in the SQL Results grid
To display ROWIDs
Select View | Toad Options | Data Grids | Dataand then select Show ROWID in editable grids.
You can achieve the same result by adding the following to the query:
select rownum, emp.* from employee emp
Remember that rownum is an Oracle pseudo-column, not stored with the table definition or data, but derived
when queried.
Toad 12.11 Getting Started
Data Grid Basics
50
To return the ROWID in the query, specify the column and the datatype:
select rowidtochar(rowid), emp.* from employee emp
Copy Column Names to the Clipboard
You can copy the names of selected columns in the data grid to the clipboard. The names are copied in
the order they are listed in the grid, for use in WHERE clauses or other tasks where you need a list of
column names.
To copy column names
1. In the data grid, click
want to copy.
(column selector) in the grid header, then select the columns that you
2. Select the sort order (alphabetical or grid order, the default).
3. Right-click the selected column list, then select Copy checked columns to clipboard.
Toad 12.11 Getting Started
Data Grid Basics
51
8
Work with Data
Throughout Toad, information is presented in a grid format. Within grids, you can customize grid views, filter
result sets, print the grid contents, and other standard operations. Grids that provide query results have
additional functionality. In most data grids you can edit data, perform calculations on grid cells, and sort and
group data, among many other things.
Understand Editable Resultsets
A data grid is fully editable providing that the query itself returns a resultset that can be updated. Query
statements must return the ROWID to be editable. For example:
Not Editable
Editable
select * from employee
select employee.*, rowid from employee
Notes:
l
l
You can substitute EDIT for SELECT * FROM. Toad translates it into the editable version of
the statement. For example, edit employee returns the same result as select employee.*, rowid
from employee.
If the resultset should be editable but remains read only, make sure the Use read-only queries
checkbox is not selected on View | Toad Options | Data Grids | Data options page.
Copy Data to Another Schema
You can quickly copy data from one or multiple tables to the same table or tables in another schema or
database. Toad builds insert statements that use array binding in the variables to copy the data, or if you prefer,
create masked data. If you set the array size to 500, then 500 rows are inserted with a single insert statement.
The array size is adjustable.
Note: Toad copies data from one schema to another between tables that have the same table name. The tables
must exist prior to running this command.
Toad 12.11 Getting Started
Work with Data
52
To copy data to another schema
1. Select and right-click one or more tables in the Schema Browser.
2. Choose Copy data to another schema from the menu.
3. Click the Source/Dest and Options tab to select destination connection, schema, and options.
4. To select tables, add and test a WHERE clause, and specify data masking, use the Tables, Where
Clauses, Data Masking tab
Tip: You can check your WHERE clauses by clicking
(Test Where Clauses).
Compare Data
You can use Toad's Compare Data wizard to compare data between tables within different schemas, or different
databases. This can be useful for comparing the data in a production and test environment, for example.
Note: This topic focuses on information that may be unfamiliar to you. It does not include all step and field
descriptions.
To access the Compare Data wizard
From the Database menu, select Compare | Data.
Select Data
Sources page
Description
Use DB Link
If your first data source is remote, select an existing DB Link.
If your first data source is local, leave this box blank.
Object Type
Tables, Views and Snapshots are supported.
Performance
Options Output
page
Description
Sort Area Size
This only affects queries going through a Database Link.
When selected:
o
The default area size is 10 MB
o
You can select to set another sort area size when
the first window closes. The default for this is also
10MB.
Optimizer Hints Use parallel hint
Default: Cleared
Select Columns
page
Description
When selected, you can set the amount of parallelism you
want. The default amount when selected is 4.
Toad 12.11 Getting Started
Work with Data
53
Column colors
Black - Columns display in both sources and can be
compared.
Red - Columns cannot be compared.
Purple - Columns display only in Source 1.
Teal - Columns display only in Source 2.
Specify columns to
uniquely identify
each row...
Description
Columns and Key
Columns
If a table has a primary key, Toad will find it automatically
and put the primary key columns in the RHS.
If no primary key is found, you can specify the field that can
be used as a primary key.
With the primary key identified (automatically or manually), Toad will use the primary
columns to identify if a row is “in both tables but with differences.”
If no primary key is identified, Toad has no way of identifying a row except by using
all columns, so no ‘differences’ tab is shown, and rows are either matches, or in one
table, or the other.
(Final Step)
Description
Page title
Your page will be labeled with one of these titles:
o
Server Side Data Comparison Using Primary Key
o
Client Side Data Comparison Using Primary Key
o
Server Side Data Comparison Using All Fields (No
Matching Primary or Unique Index is Available)
Caution: There is a risk that client-side comparisons
for very large tables could exceed memory capacity.
Source Only and
Target Only tabs
Differing Rows tab
These tabs have the same format.
You can choose to migrate selected rows only:
o
For the Source Only Rows tab, it means you insert
them into target
o
For the Target Only Rows tab, it means you delete
them from the target
You can choose to:
o
Update from source to target
This tab displays:
o
Rows from the source dataset in gray
o
Rows from the Target dataset in white
Toad 12.11 Getting Started
Work with Data
54
o
Column values that differ between source and target
are highlighted in yellow.
When you click Perform Comparison, the row count is performed first. The number
in parenthesis on each tab indicates how many rows are in each grid. The + means
Toad hasn't fetched all the rows yet.
Scroll down in the grid to update that number.
The Row Counts tab will either say “Row Counts Differ” or “Row Counts Match.”
DML:
If you choose to update via Array DML, every column has to be updated, even if the
value didn’t change. It may also fire triggers that might not otherwise fire. The nonarray DML option will update each row with only the data that has changed.
From the last three windows of the Compare Data wizard you are now ready to view the differences between
your data sources.
l
The first window reviews rows in Source 1 that are not in Source 2.
l
The second window reviews rows in Source 2 that are not in Source 1.
l
The last window reviews all differences.
You must run the SQL code for each window as described below.
To make dataset editable
On the Review Differences page, select the Editable Dataset checkbox.
Note: In some editions of Toad, you can delete rows from one table, and insert them into the other directly
in the grid.
To review rows
1. Perform any desired optional steps:
l
Click the View/Edit SQL button to view or edit the SQL used to compare differences. You can
make changes in the Edit SQL dialog box.
l
Click Check to verify that the query parses correctly.
l
Click OK to apply changes to your query.
l
Click Execute to find differences in the columns you want to compare.
To delete selected rows
1. Select the rows you want to delete.
2. Right-click and select Delete Selected Rows.
To delete all rows
Right-click and select Delete All Rows.
Toad 12.11 Getting Started
Work with Data
55
Compare Data Duplicates
Use this dialog box to view record duplicates based on user input.
To view record duplicates
1. Select Database | Compare | Data Duplicates
2. Select the Owner, Object Type and Object from the drop-down lists. A list of columns is displayed
below.
Now, you can either:
Find duplicates on all columns
Check the Find duplicates on all columns
option button.
Do not select any columns in the list.
Find duplicates on just selected columns
Check the Find dupes of selected columns
option button.
Select one or more columns in the column list.
On the Duplicate Data tabs, an additional column called Occurences is added to the end of the grid
to display the number of resulting duplicates.
To edit duplicate data
1. From the Table Data Duplicates window, select Owner and Table from the drop-down lists.
2. Click the Duplicate Data (Editable) tab.
3. Click the cell you want to edit and make your changes.
4. Click
on the toolbar.
Insert and Delete Rows
The dataset must be editable for you to make any changes. Understand Editable Resultsets
To insert a blank row
Click
on the data grid toolbar.
To copy an existing row
Right-click the cell you want to copy and select Duplicate Row. If you have a sequence set, then the sequence
number advances when you finish editing.
To delete a row
Click
on the data grid toolbar.
Toad 12.11 Getting Started
Work with Data
56
Post/Revert Edited Data
The dataset must be editable for you to make any changes. Understand Editable Resultsets
To post data
1. Make changes to an editable resultset in the data grid.
2. Click
in the grid navigator.
To revert data
Click
in the grid navigator.
Edit Data in Popup Editor
You can view and edit data in a Popup Editor. This feature is helpful when there is too much data to view in the
data grid.
Note: The dataset must be editable for you to make any changes. Understand Editable Resultsets
To edit data in the Popup Editor
Right-click a cell in the data grid and select Popup Editor.
Perform Calculations on Grid Cells
You can perform basic calculations on data grid cells, such as finding the sum or average of the selected cells.
Note: This feature is not available if Row Select is enabled. To disable Row Select, right-click the grid and clear
the Row Select option.
To perform calculations on grid cells
1. Select adjacent cells in the grid.
Note: Calculations on non-adjacent cells is not supported.
2. Click
in the grid toolbar (CTRL+N). The calculations display in a new row below the grid.
Tip: You can also right-click the grid and select Calculate Selected Cells.
3. To include additional types of calculations (such as the average or count), click the arrow by
select the appropriate options.
and
Use the Calculator
You can access a calculator within Toad data grids. To use the calculator, the table must be editable.
Understand Editable Resultsets
Toad 12.11 Getting Started
Work with Data
57
To access the calculator
1. Click in a numeric cell. A drop-down arrow displays.
2. Click the arrow to display the calculator.
Toad 12.11 Getting Started
Work with Data
58
9
Work with Database Objects
Toad enables you to view, add, modify, and get information about database objects. You can work with these
objects quickly and without having to use SQL commands.
Describe Objects
You can use the Describe Objects feature anywhere in Toad to find objects and display their information in the
Describe Objects window. The Describe Objects window displays the same information you would see in the
right-hand side of the Schema Browser.
Note: You can describe many objects types through database links. However, the following object types are not
supported: policy, policy group, java, refresh group, resource groups/plans, sys privs, and transformations.
To immediately describe the object
1. Select the object and press F4.
Tip: You can also right-click the object and select Describe.
2. If multiple objects have the same name, select the appropriate object from the Multiple Object Found
window. (This only applies to the object types in DBA_OBJECTS.)
To specify the object schema and name before describing the object
1. Press CTRL+D to open the Quick Describe window.
2. Enter the object name in the Object Name field. You can complete the rest of the fields to refine your
search. These fields are helpful when multiple schemas may contain objects with the same name, or
when different object types have the same name (for example, a SYSTEM user and table).
3. Click Describe and Close to open the object in the Describe Objects window and close the Quick
Describe window. If you click Describe instead, the Quick Describe window remains open.
Toad 12.11 Getting Started
Work with Database Objects
59
Object Search
Object Search searches all database objects, table columns, index columns, constraint columns, trigger
columns, and procedure source code for a user entered phrase. Each of the previously listed items can be
searched or excluded from the search by using options.
To access Object Search
Do one of the following:
l
From the main toolbar, click
.
l
From the Search menu, select Object Search
Tip: Select Wrap around to continuously loop the search, instead of displaying a message that the
search is done.
To create an object search action
Cick
on the Automation Designer, DBMisc tab.
Search Term
Specify your search term in the box. You can select to search for an exact match, starts with, occurs anywhere,
and you can specify a case-sensitive search by selecting that box.
Object Status
If desired, you can limit your search to Valid or Invalid objects. The default choice is to search both.
Specifying your Search
The object search is an extremely powerful feature. You can search for almost anything or combination of things
you can conceive.
By default, Toad searches through all objects in the schema you specify to find the search term you enter.
You can limit your search to:
l
Schemas
l
Object names
l
Column Names
l
Source
l
Any combination of these
Schemas to Search
Select the schemas you want to search. You can right-click in this area to select all, invert your selection, and
otherwise control your selection options.
Toad 12.11 Getting Started
Work with Database Objects
60
Search Object Names
When the search object names box is selected, you can select object types from the object list. You can rightclick in this area to select all, invert your selection, and otherwise control your selection options.
Note: Currently the DB Admin module is required to search the following objects: Contexts, Dimensions,
Directories, Evaluation Context, Library, Operators, Policies, Policy Groups, Profiles, Refresh Groups, Resource
Plans, Rules, Rule Sets, Scheduler Chains, Scheduler Jobs, Scheduler Job Classes, Scheduler Programs,
Scheduler Schedules, Scheduler Windows, Scheduler Window Groups, and Tablespaces.
Search Column Names
When the search column names box is selected, you can select object types with columns from the list. You can
right-click in this area to select all, invert your selection, and otherwise control your selection options.
Source Search
The Search Source area of the window uses the Oracle INSTR function to determine if the search term exists in
a given object's source. Because of this, when performing a Source Search, the search always searches as if
the search team has specified Occurs anywhere, regardless of what is selected in the Search term area.
Copy Objects to Another Schema
You can copy objects to another schema.
To copy objects to another schema
1. Click
on the Standard toolbar to open the Schema Browser.
2. Right-click the object you want to copy in the left-hand side and select Create in another schema.
3. Select export settings and click OK. See Export DDL in the online help for more information.
4. Enter the destination connection and destination schemas.
5. To review the script to create the objects, click the Script tab.
6. Click Execute.
Create or Alter Objects
Toad lets you select Oracle object parameters and generate a DDL statement to create or alter objects. It is
generally a good idea to review the DDL statement before executing it. When you execute the statement, Toad
passes it to the database, and the object is created or altered.
The options to create or alter an object in Toad follow the parameters defined by Oracle. If you need clarification
on what an option means or how it should be used, see Oracle's documentation for more information. Oracle
provides detailed documentation about objects, including their purpose, properties, and restrictions.
Notes:
Toad 12.11 Getting Started
Work with Database Objects
61
l
l
l
Toad strictly adheres to the database security. Consult your DBA to learn what privileges you have.
You can also find detailed information about parameters in Knowledge Xpert. Knowledge Xpert is an
extensive Oracle technical resource which you can search in Jump search. Jump Search
You can use an existing object as a template when creating a new one. Use Existing Object as Template
for New Objects
To create an object
1. Click
on the Standard toolbar to open the Schema Browser.
2. Right-click on the object type in the left-hand side and select
.
Note: You can also create an object by selecting Database | Create | <Object type>.
3. Complete the fields as necessary.
4. To add the object to the Project Manager, select Add to Project Manager.
5. To view the CREATE statement, click Show SQL or select the SQL tab.
6. Click OK or Execute to create the object immediately. You can also schedule the script to run later.
To alter an object
To alter or edit an object, double-click on it in the Schema Browser. To rename an object (if permitted) press F2.
Note: You cannot make any changes on the Alter Index | Column tab because Oracle does not permit an index
to be altered that way. To alter an index, send the script to the editor (with a DROP command), edit the script,
and then run it. As an alternative, you can right-click the index then choose Create Like. Enter a name for the
new index, make the changes, and then drop the original index.
Use Existing Object as Template for
New Objects
You can use an existing object as a template for creating a new object. Toad loads the original object's
properties in the Create window for you to edit as necessary and execute.
Note: This feature is not available for all object types.
To create an object based on an existing one
1. Click
on the Standard toolbar to open the Schema Browser.
2. Right-click the object you want to use as a template in the left-hand side and select Create Like.
3. Complete the fields as necessary.
4. To view the CREATE statement, click Show SQL or select the SQL tab.
5. Click OK or Execute to create the object immediately. You can also schedule the script to run later.
Toad 12.11 Getting Started
Work with Database Objects
62
Drop (Delete) Objects
Many objects can be dropped directly from the Schema Browser. Once you confirm the drop, it cannot
be reversed.
Note: If you accidentally drop a table on Oracle 10g or later, you may be able to recover it from the recycle bin.
Flashback Tables (Recover Dropped Tables)
To drop objects
Select an object in the left-hand side and click
additional options:
in the toolbar or press DELETE. Tables have
Cascade
Constraints
Deletes all foreign keys that reference the table.
Purge
Bypasses the recycle bin and completely drops the table. Purged tables
cannot be recovered.
Flashback Tables (Recover Dropped
Tables)
In Oracle version 10g and later, a recycle bin is available to retrieve tables and associated objects (such as
indexes, constraints, and triggers) you have dropped from the database. From the Schema Browser's Recycle
Bin page you can access this bin and retrieve dropped tables if necessary.
To flashback a table
1. Click
on the Standard toolbar to open the Schema Browser.
2. Select the Recycle Bin in the left-hand side.
3. Select the table you want to recover from the list and click
.
4. Restore the table with the original name or a new one.
View Parent/Child Datasets in the
Schema Browser
When you view a table's data in the Schema Browser, you can split the window to also show child or parent
tables in a new detail grid. You can also change the query for the detail grid.
Toad 12.11 Getting Started
Work with Database Objects
63
To view parent/child datasets in the Schema Browser
1. Select a table in the Schema Browser.
2. Select the Data tab and click
on the Data tab toolbar.
If the table has a single foreign key, Toad automatically displays the related table. If there is more than
one foreign key, click the arrow beside
remembers your selection.
3. To edit the query in the detail grid, click
on the detail grid toolbar and select a table. Toad
on the detail grid toolbar.
Create, View and Modify Object
Privileges
You can assign object privileges from the Create or Alter User windows, or from the Privileges window.
To access the Add Object Privileges window
1. On the main toolbar, go to Database | Create | User.
2. On the Object Grants tab, click Add.
3. Select All or Specify.
o
If you will specify privileges, select an Object Type to select the available privileges.
4. Select an Object Type and choose objects to grant privileges on, using the arrow buttons to move those
objects to the Grants grid on the right.
The Privileges window allows you to view, grant, and revoke privileges on a database object. You can view all
users and their privileges. If you are not the object owner, you can only grant privileges if you have been given
the "grant option."
To access the Privileges window
1. Click
on the Standard toolbar to open the Schema Browser.
2. Select a table, view, sequence, or procedure on the left-hand side.
3. Click
on the left-hand side toolbar. Grants are highlighted in blue and admin grants in yellow.
Tip: If you do not see all users, make sure Hide privileges granted by other users or Hide users/roles
with no privileges assigned is not selected.
Configure Grantees
From the System Privileges window you can grant or revoke selected privileges to/from a selected user. In
addition, you can do the same to a selected role or roles.
Toad 12.11 Getting Started
Work with Database Objects
64
To grant or revoke a privilege
1. Click
on the Standard toolbar to open the Schema Browser.
(Configure Grantees). Alternatively, you can
2. Select a privilege (listed under Sys Privs) and click
select Configure Grantees from the right-click menu.
3. Check or clear the appropriate boxes to grant or revoke privileges to users or roles.
Look Up Foreign Keys
When you are editing table data in the Schema Browser, you can look up foreign keys and enter the associated
data into the selected table.
Foreign key lookup will also work when the grid is in Read Only mode. You can disable this feature from the
Toad Options | Schema Browser | Data and Grids | Enable FK Lookup.
To lookup foreign keys
1. In the Schema Browser, click the Tables tab.
2. Select the table you want to edit and in the details pane click the Data tab.
3. Click in a column that has foreign keys. Click again to activate Editing mode. A drill down button
displays.
4. Click
to display the rows in the referential table.
5. To enter data in appropriate columns in the data grid, select a row and click OK.
The Foreign Key Lookup Window
Within the lookup window, all foreign key constraints are included. If you want Toad to ignore disabled
constraints, see Toad Options | Schema Browser | Data.
You can filter rows by typing or by directly editing the query.
To filter rows by typing
1. Make sure the Filter by box in the lower left is selected.
2. Put your cursor in one of the displayed columns. You can now filter by typing (if you type "ab" it will filter
out rows that do not begin with "ab").
To filter rows by editing the query
1. Click Edit Query.
2. Edit the query within the editing window.
3. Specify variables by clicking the Variable button and entering variable information.
4. Check that your query syntax is accurate by clicking the Check button.
5. Click OK to run your new query and filter the lookup grid.
Toad 12.11 Getting Started
Work with Database Objects
65
Compare Objects
Compare Individual Objects
You can compare individual objects or multiple selected objects to other objects from the Schema Browser. All
objects accessible from the Schema Browser can be compared to other objects, but the results are directed to
different windows depending on what is selected for comparison.
l
l
l
If you select one object to be compared to another object, the comparison is directed to the Single
Schema Object Compare window. See the rest of this topic.
If you select multiple Users (schemas) the comparison is directed to the Compare Databases window,
which is filtered to only those objects on the Object Set tab. Compare Databases
If you select multiple objects other than Users, the comparison is directed to the Compare Schemas
window, which is filtered only to those objects on the Object Set tab. Compare Schemas.
To compare objects
1. In the Schema Browser, right-click on an object.
2. Select Compare with another object. The Single Schema Object Compare window is shown.
Note: Reference source information will be filled in for you.
3. Enter comparison source information (a text file or an object in a live schema).
Select options to apply:
Compare columns only
Applies only to tables, views, and
materialized views.
Alphabetical
Arranges columns alphabetically
before comparing.
Format before comparing
Formats both files consistently so that
cosmetic differences do not impact
your results.
4. If you are using Toad with the optional DB Admin Module, you can choose to view your results in one
of two ways:
Results as File Compare
Use the Compare Files utility to
compare the two selected objects.
See Compare Files and Objects in
the online help for more information.
Results as Sync Script
Only available if the objects chosen
have the same name, and are in
different schemas, this option the
objects and creates a sync script.
Toad 12.11 Getting Started
Work with Database Objects
66
Compare and Synchronize Multiple Tables
The Toad Compare Multiple Tables wizard makes it simple to compare more than two tables. You simply point
Toad the schemas, then synchronize the data in the tables of those two schemas.
Note: This feature will synchronize the data in the compared tables, but there is not an option to compare the
data differences first. To compare the data, go to Database | Compare | Data.
To compare and synchronize multiple tables
1. From the mail Toad menu, select Database | Compare | Compare Multiple Tables. In the Automation
Designer, you can select your app, then double click
.
2. Make selections according to the following tables.
Schemas and Synchronization tab
This tab controls the selection of schemas to be compared and the way that they are compared and
synchronized.
Option
Description
Schemas
Select the source and target databases and schemas that contain the tables that you
want to compare.
There are two different techniques of synchronization that this feature can perform.
Which one Toad uses depends on what you do on this tab.
l
l
If the tables to be compared are in the same database, use the same
connection to access the source and target schemas. In this case, Toad can
synchronize the tables with just two SQL statements per table: a DELETE and
a MERGE. All of the work is performed by the database, so the data does not
get fetched to your client PC, and you will not run out of memory if you are
synchronizing large tables. This method is the faster method.
If the source and target schemas are in different databases, select Allow Toad
to create a temporary DB Link from Target to Source. In this case, Toad
creates a private database link on the target database that points back to the
source. This allows Toad to join the tables and perform the DELETE and
MERGE operations as if the tables were in the same database. The database
link has full TNS information, so there is no need for an entry to exist in the
TNSNames.ora file on the target server. Toad drops the link when the
synchronization is finished.
Note: Toad refers to the previous two methods as Comparison by SQL.
l
Synchronization
If you cannot allow a database link to be created, and the schemas are in
different databases, then Toad must fetch all of the rows from each table to
your PC and then compare them row by row. This is the slowest and most
memory-intense option. If possible, use the database link when the schemas
are in different databases. Note: Toad refers to this method as Row-by-row
comparison.
Select the way that you want Toad to perform the synchronization:
Toad 12.11 Getting Started
Work with Database Objects
67
Option
Description
l
Sync target tables immediately: Select this option to start the synchronization
the moment you click
to start the processing.
When this option is selected, Array DML is active and selected by default.
Array DML means that Toad will apply deletes in batches of up to 1000 rows at
a time, and inserts/updates in batches of up to 100 rows at a time. Array DML
greatly increases the speed of the synchronization, so you should leave it
selected. In this mode, update statements update every column in the rows
being synchronized, even if only one column value actually changed. If you do
not agree with this methodology, uncheck Array DML. Note: If a large
percentage of the rows in a large table need to be synchronized, running the
synchronization without Array DML may be very slow compared to using Array
DML.
l
Select Create one script for each table or Create one script for all tables
and then specify the output folder or file name.
Tables tab
This tab enables you to handle table names that do not match or to compare a subset of the tables in the
selected schemas. To compare all of the tables with matching names in your selected schemas, do nothing
on this tab.
Option
Description
Match tables
automatically
Both of these options are selected by default and indicate that you do not want to refine
the table selection further.
and
Otherwise:
Table names
match exactly
To compare a subset of the tables, deselect Match tables automatically.
To map table names that do not match, deselect Table names match exactly.
Or, deselect both if appropriate.
Table name
filter
To load only specific tables based on their names, enter standard filter syntax here.
Load
Click this option to view a list of tables that are to be compared.
Include
Select this checkbox for every table that you want to include in the synchronization.
To map non-identical table names, use the dropdown selector in the Target column to
map a target to the source table listed in that row under Source.
Validate
To check the compatibility of the source and target tables for comparison, click this
option. See Potential comparison problems for examples.
Options Tab
This tab enables you to determine what Toad does when it finds anomalies during the initial comparison.
Toad 12.11 Getting Started
Work with Database Objects
68
Option
Description
If columns don't
match exactly
Select what you want to do if the source and target tables do not have the same
number of columns.
If an error
occurs during
synchronization
Select what you want to do if there are synchronization errors.
Commits are automatic, but you have some control over them with this option:
Rollback current table and continue directs Toad to issue a commit after each table
(except if the synchronization of that table is rolled back due to an error).
Rollback all tables and stop directs Toad to either commit at the end of the process or
roll it back when the first error happens.
Note: It is not possible to provide the option to commit or do not commit, because DDL
occurs at the beginning and end of each compare and synchronization
(disable/enable of constraints and possibly triggers, create/drop database link), and
therefore commits are implicit in most cases.
If unsupported
datatypes are
found in a table
Select what you want to do if a table contains an unsupported datatype. See Potential
comparison problems for examples.
Triggers
By default, triggers on the compared tables are disabled so that they do not cause
DML to be performed on child tables that may also be compared and synchronized by
Toad. Double operations like this will cause errors. Clear this selection if you need the
triggers to fire.
If any table is to
be skipped for
incompatibilities
Select what you want to do when incompatibilities are found during the comparison.
Status Tab
This tab is shown automatically when you click
the operations on the tables that you specified.
to start the processing. It shows the progress and results of
The grid shows a row for each table to be compared. Toad makes two passes through the list, first to evaluate
the tables for compatibility and to disable foreign keys, and the second to perform the comparison and
synchronization.
l
l
For Comparison by SQL (performed by the database), Toad displays the number of rows that are
deleted and merged (inserts and updates).
For a Row-by-row comparison (performed by Toad on your PC), this window displays details about the
rows that are inserted, deleted, and updated, as well as the number of matching rows (the Matches
column). The Time Remaining column shows how much time remains on each step (one step is deletes,
the other is insert and update).
Potential comparison problems
The following chart shows potential validation problems that can arise from incompatible source and target
tables. In this table, Supported in Row By Row Comparisons refers to comparisons performed by Toad on your
PC, and Supported in Comparison by SQL refers to comparisons performed by the database.
Toad 12.11 Getting Started
Work with Database Objects
69
Compare Schemas
You can compare entire schemas or selected subsets of schemas from the Schema Browser.
Notes:
l
l
You can compare schemas in the Base Edition, but Snapshot files and sync scripts are only available
with the DB Admin Module or Toad for Oracle Xpert Edition.
Toad also provides an easy to use Compare Schemas wizard. Compare and Synchronize Schemas
To compare schemas
1. Select Database | Compare | Schemas.
2. Complete the fields as necessary. Schemas Tab
Description
Reference Schema
(Source)
Select a schema connection or schema definition file to use as the basis
for comparison. If you execute the sync script, the target schema is
updated to match the reference source.
Tip: If you select Create Schema Definition File, you can use variables in
the filename. By default, Toad includes the %DATEFILE% and
%TIMEFILE% variables, which inserts the current date and time into the
filename when it creates the definition file.
Targets and Output
Click
in the Live Schemas or Def Files field to add a target schema
for comparison. You can repeat this step to compare multiple target
schemas to the source.
Tip: Right-click a target to edit it, delete it, or switch it with the reference
source.
Options Tab
Description
Object Types to
Select the object types you want to compare. Reducing the object types
Toad 12.11 Getting Started
Work with Database Objects
70
Compare
reduces the amount of time it takes to complete the comparison.
Tip: Right-click to select or clear all fields, and to save or recall your
settings.
Object Set Tab
Description
Specify Object Set
Select to determine specific object sets to compare. This lets you limit your
comparison even more than the Options tab. Note: If Compare Schemas
was opened as the result of the Compare with another object command
targeting a multi-object selection, the selected objects are shown here.
Click
to add an object set. If you already have objects loaded, a
confirmation dialog ask you if you want to clear the grid before loading the
new objects. Click Yes to start over, or No to append the new objects into
the grid.
3. Click
to execute, or save or schedule the selections as a Toad action. See Automation Designer
Overview in the online help for more information.
Tip: You can execute actions from the command line. See Execute Actions from the Command Line in
the online help for more information.
Toad 12.11 Getting Started
Work with Database Objects
71
4. Review the differences on the Results tab. This tab has a filter that enables you to narrow the focus if
needed. Additionally, the objects are grouped by type by default. To remove the grouping, right-click the
list tree and deselect Group by Object Type.
If you want
to...
Show the
sync script
for selected
objects.
Complete the following:
Select the objects and click
.
View the
differences
for one
object
Select the objects and click
View the
differences
for another
target
Select the target in the Target Schema field (only applicable if you selected more
than one target for comparison).
Exclude
objects
from the
next
comparison
Uncheck any items that you want excluded from the next run of this comparison, and
then click
(
). You can view this file on the
Create Exclusion File
Options | Misc
Options tab, from which you can also specify a different exclusion file for the next
comparison.
Save the
results
Click
View a
summary of
the
differences
Click
(Show Summary) to view a summary that shows the number of objects that
are in the source only, in the target only, and in both source and target with
differences between them.
Rebuild a
table
Enabled if there are column differences (such as column order). Right-click the table
and select Send to Rebuild Table window.
Redefine a
table
Enabled for most table differences. Right-click the table and select Send to
DBMS Redefinition Wizard.
Redefine
partitions
Enabled if there are partitioning differences. Right-click on a partition then select
Send to Partitioning Wizard in Space Manager (requires a licensed copy of that
software).
or
.
to save to a file or to an Excel spreadsheet.
5. To sync the schemas, select the Sync Script tab and click
to execute immediately from the Editor or
to schedule its execution.
Caution: Review this script thoroughly before executing it to prevent unintentional data loss.
Toad 12.11 Getting Started
Work with Database Objects
72
Compare and Synchronize Schemas
The Compare Schemas Wizard provides an easy to use interface for doing a one-to-one comparison between
schemas. Based on your specifications, the wizard generates a script that you can save or run immediately to
synchronize the two schemas. The wizard also enables you to add or check in the script to source control.
To use the wizard
1. Go to Database | Compare | Schemas.
2. Select the Schemas tab.
3. Under Source, select the schema on which to base the comparison.
4. Under Target, select the schema to compare to the source schema.
5. Under Compare Object Types, select the types of objects that you want to compare.
6. Select the Options tab.
7. Select any additional conditions to qualify and filter the comparison.
Object Types: Enables further refinement of the comparison for certain object types.
Storage Clause: Enables the comparison of specific (or all) storage attributes of the objects.
Script: Specify options for the output script.
Filter: Specify filter criteria to refine the objects that are selected.
8. Click Next.
9. Review the compare settings.
10. Click Compare.
11. Review the differences.
l
l
Click any object in the list to view the DDL that will be issued on the target schema by the
synchronization script.
Deselect any object that you want to exclude from the synchronization script.
12. Click Next.
13. Review the script syntax. To copy the script to store it outside Toad, click Copy to Clipboard.
14. Click Next.
15. Select one or more ways in which to deploy the synchronization script:
Deploy: Specify a local directory in which to store the script file.
Check into Source Control: Specify the path to a directory where the script is to be stored in the version
control system.
Send to Editor: Open the script in the Toad Editor or further editing. To deploy the script when you click
Next, select Execute Immediately.
Compare Multiple Schemas
This feature is ideal for comparing multiple schemas in one database to the same schemas in
another database.
Toad 12.11 Getting Started
Work with Database Objects
73
Note: You can compare multiple schemas in the Base Edition, but Snapshot files and sync scripts are only
available with the DB Admin Module or Toad for Oracle Xpert Edition.
Compare schema-level objects (tables, indexes, views, etc.) in every schema across two databases, without
individually identifying each source and target schema.
To compare multiple schemas
1. Go to Database | Compare | Multiple Schemas.
2. Select your source and target databases (these can be the same database).
3. Click the Schemas tab and specify your selection criteria:
See the table below for more detail.
4. Click Load. You can select/deselect listed schemas if you have chosen Manually... in step 3 above.
5. Click the Options tab; the options are the same as the basic Schema Compare window.
Compare Schemas
o
Select the items you want to compare
Tip: Right-click to select or clear all fields, and to save or recall your settings.
6. Click the Output tab to specify:
o
Your output folder (files are named based on the schema name).
o
Create difference summary files
o
Create difference detail files
o
Create sync script files
o
Note: Sync script files are created in Toad's Base Editions; running them is available with the
DBA Admin Module.
7. Click the run button, labeled 'Begin Comparison.'
The Results tab appears, with your selected outputs displayed.
8. Review differences on the results tabs, depending on the outputs you selected in step 6 above.
Using the Schemas tab
In step 3 above, you can ask Toad to automatically match schema names, or manually specify the
matching criteria.
When to match up
schemas:
Choose: Automatically, at time of comparison
l
l
You cannot then select or deselect schemas listed after you click
Load.
Built-in schemas like SYS, SYSTEM, etc, are automatically
excluded, and this list of automatically excluded schemas is
configurable
Choose: Manually, before comparison
l
l
Click in the Target column to change the target schema. (A dropdown arrow appears.)
Use alternately-named schemas, as described below under
Manipulate source schema....
Toad 12.11 Getting Started
Work with Database Objects
74
How to match up
schemas:
Choose: Match schema names exactly
l
Once listed, if Automatically... is selected as described above,
you can select or deselect schemas to compare.
Choose: Manipulate source schema name to find target schema name
l
l
l
Prepend text - For instance, if your source and target schema
names are Dev_Employees and Employees.
Append text - For instance, if your source and target schema
names are Employees_Test and Employees.
Search for/Replace with - For instance, if you search for Dev and
replace with Prod if your source and target schema names are
Dev_Employees and Prod_Employees.
On the Results tab, you can:
l
l
Re-compare selected schemas
Send selected or all sync scripts to the Editor (with the DB Admin Module or Toad for Oracle
Xpert Edition)
Depending on the outputs you selected in step 6 above, you can also view these tabs:
l
Difference Details (tree view)
l
Difference Summary
l
Sync Script
The list of schemas that are automatically ignored is in Toad.ini.
If you want to adjust it, find this line and make your changes:
MultipleSchemasToIgnore='ANONYMOUS', 'APPQOSSYS', 'CTXSYS', 'DIP', 'DBSNMP', 'EXFSYS', 'FLOWS_
FILES', 'MDDATA', 'MDSYS', 'MGMT_VIEW', 'OLAPSYS', 'ORACLE_OCM', 'ORDDATA', 'ORDPLUGINS',
'ORDSYS', 'OUTLN', 'OWBSYS', 'OWBSYS_AUDIT', 'SI_INFORMTN_SCHEMA', 'SPATIAL_CSW_ADMIN_USR',
'SPATIAL_WFS_ADMIN_USR', 'SYS', 'SYSMAN', 'SYSTEM', 'WMSYS', 'XDB', 'XS$NULL'
The APEX schemas are also automatically ignored. If you don’t want that, find this line and change the
‘1’ to a ‘0’:
MultipleSchemasIgnoreApex=1
Compare Databases
You can compare database-level objects such as tablespaces, roles, users, and so on between databases or
Database Snapshot files
This feature is only available with the DB Admin Module, which is included in several Toad Editions or can be
purchased separately.
To compare databases
1. Select Database | Compare | Databases.
2. Complete the fields as necessary. Toad 12.11 Getting Started
Work with Database Objects
75
Databases Tab
Description
Reference Source
Select a live database or database definition file to use as the basis for
comparison. If you execute the sync script, the target database is updated
to match the reference source.
Tip: If you select Create Database Snapshot File, you can use variables
in the filename. By default, Toad includes the %DATEFILE% and
%TIMEFILE% variables, which inserts the current date and time into the
filename when it creates the definition file.
Targets and Output
Click
in the Live Databases or Snapshot Files field to add a target
database for comparison. You can repeat this step to compare multiple
target databases to the source.
Tip: Right-click a target to edit it, delete it, or switch it with the reference
source.
Options Tab
Description
Database Object
Types
Select the object types you want to compare. Reducing the object types
reduces the amount of time it takes to complete the comparison.
Tip: Right-click to select or clear all fields, and to save or recall your
settings.
Safe Drop on users,
tablespaces, and
profiles
Select to only drop a user or tablespace if it does not own any objects, or
a profile if no users are assigned to it.
Object Set Tab
Description
Specify Object Set
Select to determine specific object sets to compare. This lets you limit your
comparison even more than the Options tab. Note: If Compare Databases
was opened as the result of the Compare with another object command
targeting a selection of Users, the selected Users are shown here.
Click
to add an object set. If you already have objects loaded, a
confirmation dialog ask you if you want to clear the grid before loading the
new objects. Click Yes to start over, or No to append the new objects into
the grid.
3. Click
to execute, or save or schedule the selections as a Toad action. See Automation Designer
Overview in the online help for more information.
Tip: You can execute actions from the command line. See Execute Actions from the Command Line in
the online help for more information.
Toad 12.11 Getting Started
Work with Database Objects
76
4. Review the differences on the Results tab. Review the following for additional information:
If you want to...
Complete the following:
Show the sync script for
selected objects.
Select the objects and click
.
View the differences for
one object
Select the objects and click
View the differences for
another target
Select the target in the Target Database field (only applicable if you
selected more than one target for comparison).
.
5. To sync the databases, select the Sync Script tab and click
to execute immediately from the Editor or
to schedule its execution.
Caution: Review this script thoroughly before executing it to prevent unintentional data loss.
Rebuild Objects
About Rebuilding Objects
Use the Rebuild Multiple Objects window to identify objects that need to be rebuilt, and then set criteria to
rebuild them simultaneously.
Rebuild Multiple Objects
You can also rebuild one index or table at a time from the Schema Browser, with a simpler interface.
Rebuild a Table
Use this function to rebuild a table, including dropping and renaming columns.
Notes:
l
You can simultaneously rebuild multiple tables with the Rebuild Multiple Objects feature.
l
l
Rebuild Multiple Objects
You must own the schema in order to rebuild a table from it.
To rebuild a table
1. Click
on the Standard toolbar to open the Schema Browser.
2. Right-click the table in the left-hand side and select Rebuild Table.
Tip: You can also select Database | Optimize | Rebuild Table.
3. Select settings as necessary on the Options tab.
Toad 12.11 Getting Started
Work with Database Objects
77
4. Select parameters as necessary on the Table Storage and Index Options tabs.
Note: The parameters in this window are defined by Oracle. See Oracle's documentation for more
information. You can also find detailed information about parameters in Knowledge Xpert. Knowledge
Xpert is an extensive Oracle technical resource which you can search in Jump search. Jump Search
5. To add, edit, or drop a column, use the toolbar buttons on the Columns tab.
6. To view the ALTER statement, select the Script tab.
on the Rebuild Table toolbar. Note: You can also use the toolbar buttons
7. To execute the rebuild, click
to schedule, copy, regenerate, and save the script.
Rebuild an Index
This procedure explains how to rebuild a single index.
Note: You can rebuild multiple indexes and tables at the same time. Rebuild Multiple Objects
To rebuild an index
1. Click
on the Standard toolbar to open the Schema Browser.
2. Right-click the index in the left-hand side and select Rebuild Index.
3. Select parameters as necessary.
Note: The parameters in this window are defined by Oracle. See Oracle's documentation for more
information. You can also find detailed information about parameters in Knowledge Xpert. Knowledge
Xpert is an extensive Oracle technical resource which you can search in Jump search. Jump Search
4. To view the ALTER statement, select the SQL tab.
5. Click OK.
Rebuild Multiple Objects
The Rebuild Multiple Objects feature allows you to simultaneously rebuild multiple indexes, tables, or
LOB segments.
To rebuild multiple objects
1. Select Database | Optimize | Rebuild Multiple Objects.
2. Select the Indexes, Tables, or LOB Segments tab.
3. Click the arrow beside
to load objects.
4. To quickly eliminate objects that do not need to be rebuilt:
a. Select the Thresholds and Performance Options tab, and complete the Consider objects for
rebuild only if fields.
b. Select the tab where you the loaded objects.
c. Click the arrow beside
and select Delete rows for items that fail consideration thresholds.
Toad 12.11 Getting Started
Work with Database Objects
78
5. To have Toad recommend indexes to rebuild:
a. Select the checkbox beside indexes you want to examine.
b. Select the Thresholds and Performance Options tab and complete the Mark indexes for rebuild
only if fields.
c. Select the Indexes tab and click
.
Tip: You can click
to automatically rebuild the recommended indexes, or click
to generate
a rebuild script for the recommended indexes (the script is copied to the clipboard and you can
paste it into the Editor).
6. Complete the other tabs as necessary. Review the following for additional information:
Thresholds and
Performance
Options
Use the following option to...
Use 'Online'
option
Have Toad rebuild or move the table or index while it is in use.
Storage Clause
Adjustments Extents Tab
Use the following option to...
Change Extent
Sizes to the
Following
Change the extent sizes, which overrides any options set in the top part of the
window.
Adjust Extent
Sizes to
Minimize # of
Extents
Minimize the number of extents. When this option is selected, the new extent
size for each index is calculated as follows: working size equals the total size
multiplied by the percent used.
If you opt to use this feature, make sure you examine the index before you use
it. Because the percent used is a factor, this value can only be obtained by
examining the indexes. Note that this is not the PCTUSED storage parameter.
This refers to the actual percentage of allocated storage space for the index
being used.
This working size is then passed through the Make extent this size or Round
All Extent Sizes to the Nearest Power of... algorithm, as selected. The
resulting value is the new initial_extent size. It is also the new next_extent size.
Pctincrease is set to zero.
Caution: If some indexed tables are used as large temporary tables but are
usually empty, Toad may recommend that you rebuild them because they have
zero percent used. If you use Adjust Extent Sizes during the rebuild, Toad
would build the index with small extents that may not hold all of your data later.
Avoid this by either using global temporary tables, or do not rebuild indexes
with a percent used of zero.
Storage Clause
Adjustments Tablespaces
Tab
Select options to move all objects to different tablespaces, or selectively
dependent upon their size.
Toad 12.11 Getting Started
Work with Database Objects
79
l
l
Email
Notifications
If you choose to move indexes to a tablespace based upon the size of
the index, and have chosen By Index Size on the Extents tab, size is
based on the total size of the index.
If you choose to move indexes to a tablespace based upon the size of
the index, and you have chosen By Extent Size on the Extents tab,
then the size is based on the INITIAL extent size, as opposed to the
NEXT extent size.
Select whether to send email notifications after completion. The email is sent to
the recipients defined on the Email Settings options page.
See "Email Settings" in the online help for more information.
to rebuild them immediately or
7. Select the checkboxes for objects to rebuild and click
rebuild script (the script is copied to the clipboard and you can paste it into the Editor).
to create a
Toad 12.11 Getting Started
Work with Database Objects
80
10
Work with Code
Toad provides an intuitive and efficient way to write, run, and test your SQL and PL/SQL code. Toad supports
efficient code management for a single developer or a whole team of developers.
Write Statements and Scripts
Move through Code with the Navigator
The Navigator panel displays an outline of the code in the active window. You can click on the items listed to
navigate to that statement in the Editor.
To access or hide the Navigator
Right-click the Editor and select Desktop | Navigator.
The left pane contains a list of statements, objects or package contents that are contained in the Editor. The list
is displayed in a hierarchy, with each element broken out separately. To hide any of these elements, right-click
the hierarchy and select Navigator Options.
To display the entire statement
Hover the pointer over an item in the Navigator. Information about it is displayed as a tooltip.
To jump to the statement
Click on the statement in the Navigator and the cursor jumps to that point in the Editor.
To refresh the navigator panel
Do one of the following:
l
Save the current file
l
Click the Refresh
button.
Toad 12.11 Getting Started
Work with Code
81
Pick Objects from the Object Palette
The Object Palette shows all of the objects and their columns in a selected schema. The Object Palette can be
docked to the main Toad window, so that it is available within any of your Toad windows, or you can drag it
away from its default location to use as a floating palette in a position of your choosing.
When you work in the Editor, you can use the Object Palette as a quick-reference tool to view the objects that
you might want to use as you write SQL, rather than opening the Schema Browser for that purpose. You can
also drag a table or column name from the Object Palette to Editor.
When the active connection changes the Object Palette automatically refreshes to reflect the new active
connection. Or, you can use the refresh button to refresh the list (this method queries the database).
To access the Object Palette
From the View menu, select Object Palette.
To undock and redock the Object Palette
To undock and float the palette to a new location, drag the heading area to the desired position.
To redock the palette, double click the heading area.
To view columns
In the Object Palette, click
. Columns are displayed for the selected object at the bottom of the palette.
To view objects from a different schema
1. At the top of the Object Palette, click the Schema drop-down.
2. Select the new schema from the list. Objects from that schema now display in the object list.
To change the style in which objects are listed
1. Click the drop down arrow beside
.
2. Select the style in which you want to view objects.
To insert an object into an Editor
1. Place your cursor in the Editor in the location where you want the object.
2. In the Object Palette, double-click the object you want to insert.
To perform a DESCRIBE on an object
1. In the Object Palette, select the object you want to describe.
2. Press F4 to display the DESCRIBE window.
To filter the Object Palette
1. In the Object Palette toolbar, click the appropriate filter button:
l
Project Manager filter
l
Filter tables. Create Schema Browser Filters
2. Enter the filter criteria to limit the objects shown.
Toad 12.11 Getting Started
Work with Code
82
Use Code Completion Templates
Code Completion Templates enable you to store sections of code as a template and then use a keystroke
(CTRL+SPACE) to select the named template from a list, which inserts it where your cursor is in the Editor. This
feature reduces the amount of time that you spend writing the same code over again.
Code templates are more than a single phrase and can contain line feeds, substitution variables and a cursor
position indicator.
Example
entire cursor block (crbl)
DECLARE
CURSOR c1 IS
SELECT | FROM WHERE;
c1rec IS c1%ROWTYPE;
BEGIN
OPEN c1;
LOOP
FETCH c1 INTO c1rec;
EXIT WHEN c1%NOTFOUND;
END LOOP;
CLOSE c1;
END;
Where:
l
crbl is the name of the template
l
entire cursor block is the description of the template
l
subsequent content is the body of the template
Note: Do not leave spaces between the end of the template description and the final right bracket! NT4.0 API
calls to manage profile strings have a bug that will cause reading of the templates file to fail.
To edit or create a Code Template
Toad provides a list of default templates. As you use this feature, however, you can create templates that work
better for your purposes, and you may want to edit the default templates or create new ones. You can view and
manage Code Templates from the Editor section of the Toad Options. See Code Templates Options in the
online help for more information..
To use a Code Completion Template
1. Place the cursor where you want the template code to be inserted in the Editor.
2. Type the name of the template (for example crbl) and then press CTRL+SPACE to load the body of the
template. If you do not know the name of the template, press CTRL+SPACE to select it from a list. This
list is also shown if you type a name that does not exist.
3. When a template containing substitution variables is selected, you are prompted to enter values. Enter
the values in the popup dialog, then press OK.
Toad 12.11 Getting Started
Work with Code
83
If Toad finds a single pipe ( | ) in the template body, it repositions the cursor at that point when the substitution of
the template is complete. The pipe is removed, as it is used only as a marker for the cursor position. Only one
pipe can be used this way in a code template.
Create Templates for Make Code Statement
Functions
You can create your own Make Code Statement templates.
You can set options for these templates.
See Code Assist Options in the online help for more information.
To create a Make Code template
1. From the Toad Options window, select Editor | Code Assist.
2. In the Make Code area, click Add.
3. Use the following variables to create your own language template:
l
l
l
l
%SqlVar% - this is the MakeCode variable entered in the Toad Options | Editor | Code Assist |
MakeCodeVariable box. Using a variable here is optional.
%SqlLength% - This will be replaced by the number of characters in all selected SQL, on one or
multiple lines.
%SqlText% - This is replaced by the first line of SQL you have selected.
%SqlTextNext% - This will be replaced by any subsequent lines of SQL you have selected. This
is cumulative and includes ALL subsequent lines of SQL.
Note: For the best output result, it is recommended that the %SqlTextNext% variable be included on a
separate line. Use the left and right brace for comments.
Remarks (such as template name) should be included in brackets.
4. Click OK.
Examples:
Using the following SQL:
Select *
from
Employees
and using the following code templates, you will get the results below.
Template
Result
{C# Language Template}
string SQL
string %SqlVar%& = "%SqlText%
"
= "Select * "
+ "%SqlTextNext% "
+ "from "
+ "employees "
Toad 12.11 Getting Started
Work with Code
84
Template
Result
;
{C++ Language Template}
char SQL[23];
strcpy(SQL,"Select * ");
char %SqlVar%[%SqlLength%];
strcat(SQL,"from ");
strcpy(%SqlVar%,"%SqlText%");
strcat(SQL,"employees");
strcat
(%SqlVar%,"%SqlTextNext%");
{ Java Language Template }
"Select * "
"%SqlText% "
+ "from "
+ "%SqlTextNext% "
+ "employees "
Create and Manage Code Snippets
You can create and reuse code snippets in the Editor.
Note: The file associated with these items is located in:
C:\Users\<user>\AppData\Roaming\Quest Software\Toad for Oracle\<version>\User Files\CodeSnippets.dat
To use Code Snippets
1. From the View menu, select Code Snippets.
2. Select a category of code from the box at the top of the window.
3. Select the code from the list. You can:
4. View a description of the code in the area below the code list
5. Double-click the code to insert it into the active editor tab
6. Drag and drop code into the editor
To Edit Code Snippets
1. From the Toad Options window, select Editor | Code Assist.
2. In the Code Snippets area, select the category of snippets you want to edit and then click Edit.
3. Select the snippet you want to edit, and click Edit.
4. Edit the Oracle Function or the description and click OK.
To Add Code Snippets to an existing category
1. From the Toad Options window, select Editor | Code Assist.
2. In the Code Snippets area, select the category of snippets and then click Edit.
3. Click Add.
4. Enter the code in the Oracle function box.
Toad 12.11 Getting Started
Work with Code
85
5. Enter a description in the Description box.
6. Click OK.
To Add Code Snippets to a new category.
1. From the Toad Options window, select Editor | Code Assist.
2. In the Code Snippets area, click Add.
3. Enter a category name in the Category box.
4. Enter the code in the Oracle function box.
5. Enter a description in the Description box.
6. Click OK.
To highlight a snippet
1. Place your code in the snippet you want to highlight.
2. From the Editor menu, select Highlight Snippet (CTRL+H).
Complete Code from a Pick List
Toad helps you write code by displaying a pick list with relevant object or column names. For example, if you
start typing SYS and invoke the pick list, the SYSTEM user would be included in the pick list.
Toad provides options for you to customize this behavior, such as adjusting the length of time before the pick list
displays. See Code Assist Options in the online help for more information.
To display the pick list
Press CTRL+T, or begin typing a name and pause 1.5 seconds.
Note: There are additional shortcut keys you can use with Toad Insight.See Toad Insight Pick List
Shortcuts in the online help for more information.
Use Query Templates
Toad has standard query templates, such as Show Dependent Objects or Column Counts, and you can also
create your own custom query templates. When you use a query template in the Schema Browser, Toad builds
the query with the selected objects and opens the query in the Editor.
To use a query template
1. Click
on the Standard toolbar to open the Schema Browser.
2. Select the objects you want to use for the query on the left-hand side.
3. Right-click the objects and select Custom Queries | <Query Name>.
Custom queries are designed to select from the data dictionary about the tables you select, rather than making
custom SELECT statements. For example, the following query is not valid as a custom query because there is
no specific object stated:
select * from <ObjectOwner>.<ObjectList>>
Toad 12.11 Getting Started
Work with Code
86
However, this more specific query is valid:
select *
from dba_tables
where owner = <ObjectOwner>
and table_name in <ObjectList>
To create a new query template
1. Right-click in the left-hand side of the Schema Browser and select Custom Queries | Edit
Custom Queries.
2. Click
above the query list.
3. Enter your new query name, and query.
4. Click
to create the query and add it to the selection list.
Format Code
You can have Toad format your code in the Editor. For example, you can insert spaces instead of tabs or
change the case for SQL commands.
Before formatting
After formatting
Toad 12.11 Getting Started
Work with Code
87
Code formatting is controlled by the Formatter.
See Formatter Options in the online help for more information.
To format a statement
Select the statement you want to format and click 'Format Code'
down arrow to select:
o
Format Case Only,
o
Profile Code, or
o
Formatter Options (opens the Options window).
on the Editor toolbar, or select the drop-
To format an entire script
Click
on the Edit toolbar.
You can also right-click the script and select Formatting Tools | Format Code.
Highlight Statements
You can highlight bits of code so that an explain plan is run on only that code, or so that you can see what
Toad is including as a part of the statement before you Execute it. Highlighting code uses the same logic
as SHIFT+F9.
To highlight a SQL Snippet
Place your cursor in the code you want to highlight and then press CTRL+H.
Toad 12.11 Getting Started
Work with Code
88
Fold Code Segments
Code folding lets you collapse portions of your code so that you can see more of the code you need to see.
Then you can expand it when you need to work with the folded code.
To enable code folding
From View | Toad Options | Editor | Behavior, select Enabled under Folding.
To fold and unfold code selection
The folding indicator is the icon in the code gutter that you click. By default, it is as follows:
To fold a segment, click
To unfold a segment, click
in the Editor gutter.
in the Editor gutter.
To set the appearance of the fold indicator
To change the style of the fold indicator, go to View | Toad Options | Editor | Behavior, then select from the
Style dropdown.
To change the colors of the fold indicator, go to View | Toad Options | Editor | Font and Styling, then select Fold
Indicator (appearance when a code block is expanded or Fold Indicator, Active (appearance when a code
block is folded).
Change Text to Upper or Lower Case
Capitalization Effects that you have set up in the Toad Options can override your Upper Case and Lower Case
conversions.
To change the selection to Upper Case
Select Edit | Upper Case (CTRL+U).
To change the selection to Lower Case
Select Edit | Lower Case (CTRL+L).
To change the selection to Lower Case
Select Edit | Initial Caps (CTRL+L).
Note: The Editor provides one level of Undo for any action. Select Undo from the Edit menu, or use the CTRL+Z
keystroke combination.
Swap with Previous Line
The Edit | Swap This/Prev Lines menu item switches the line your cursor is on in the SQL script with the
previous line.
For example, if the cursor is on Line 8, then when you swap, what was on line 8 would now be on line 7 and
what was on line 7 would now be on line 8.
Toad 12.11 Getting Started
Work with Code
89
View and Merge Differences
Use the Compare Files utility to compare files and scripts with other files and scripts, as well as database
objects with revisions in the VCS. This utility provides a split window composed of read-only versions of the files
that are different, plus an editable third window where the merged source code is assembled.
To open the Compare Files utility
Select Utilities | Compare Files, or click
on the toolbar of any Toad feature that works with files.
Depending on where you open the utility, there may or may not be files displayed. If files are not displayed, you
are prompted to select them. If both files are in the same directory, you can select them both at once. Otherwise,
you are prompted to select both left and right sides separately.
To customize the Compare Files interface
Click
to set the options.
View Differences
The upper two comparison windows make use of standard diff tool features:
l
The differences are color-coded with a legend to explain them at the bottom of the Compare Files
window. By default, the Compare Files window finds the next/previous differences by block, rather than
by line. You can change this option by clicking
selecting Finds next difference line.
l
(Options) in the Compare Files toolbar, then
The Compare Files toolbar provide tools for copy/paste, finding text, moving up and down through
differences, showing only different or matching lines, and switching sides.
Compare Files also shows a Differences Map on the left side of the window. The Differences Map is a visual
summary of the differences and lets you quickly change sections of the file. Colored lines show the relative
position of line mismatches. An arrow represents the part of the text currently visible in the comparison window.
You can click the thumbnail view to position the view at that point in the documents.
Note: If the Differences Map is not shown, click
in the Compare Files toolbar.
To show line numbers and white space
On the toolbar:
l
Click
to show line numbers.
l
Click
to show white space.
To view a list of differences
Click
on the toolbar. The report shows each difference and its line number.
Click
on the toolbar to view a comparison summary. The summary shows the number of matches and the
number of differences in the code on the right, as compared to the code on the left.
To view differences line by line
Click
on the toolbar. This opens the line viewer pane below the split differences window.
Toad 12.11 Getting Started
Work with Code
90
Merge the Code
The proposed merged source code is shown in the Merged Source window at the bottom of the Compare Files
window. You can revise the merged source code as needed, using tools on the toolbar, in the comparison
windows, and through direct edit.
Note: If the Merged Source window is not shown, click
on the toolbar.
Important! The Merged Source code is always based on the source in the left-hand comparison window.
To switch sides
Click
on the toolbar to base the Merged Source on the source that is currently in the right-hand comparison
window. The Merged Source code is updated to match that code because it is now in the left-hand side
comparison window.
To refine the merged code
You can use any of the following methods to refine the merged code. See also the Examples at the end
of this topic.
Select a line, then click the left or right arrow
on the toolbar to use that line in the Merged Source. For
example, to use the line from the left-hand window, click the arrow that points to the left.
Click the diamond beside any line to add that line to the merged code in the Merged Source window. When you
choose a line, that change is marked as resolved and the diamond fills in with solid color.
Make any inline changes directly to the Merged Source code as needed.
To view the status of your merge work
The status bar below the Merged Source window keeps track of how many issues there are to resolve and how
many are resolved.
To revert merge changes
Click
on the toolbar to reload and compare the files again. Existing changes in the Merged Source window
are cleared with this action.
To accept the merged code
You cannot overwrite either of the two input files. Use the Save button to save the merged code to a new file.
This preserves the original two files in case they are needed.
Examples
Deleted line: A line was deleted (therefore it exists on the left side but not the right). The following options
are possible:
Option 1: Click the diamond next to that line on the left (or click
Option 2: Click the diamond next to that line on the right (or click
) to keep that line in the Merged Source.
) to delete that line from the Merged Source.
Modified line: A modified line exists on both the left and right sides. The following options are possible:
Option 1: Click the diamond next to that line on the left (or click
Merged Source.
) to use that line from the left in the
Toad 12.11 Getting Started
Work with Code
91
Option 2: Click the diamond next to that line on the right (or click
Merged Source.
) to use that line from the right in the
Added line: A line was added (therefore it exists on the right side but not the left). The following options
are possible:
Option 1: Click the diamond next to that line on the left (or click
Merged Source.
Option 2: Click the diamond next to that line on the right (or click
Merged Source.
) to delete the corresponding line from the
) to keep the corresponding line in the
Preview Query Results
Use the Describe (Parse) Select Query function to see what columns would be returned if the query were
executed. This is useful for tuning a LONG query before it is executed.
To describe a query
Select Editor | Describe (Parse) Select Query (CTRL+F9).
Save Query Results
Any of Toad's window query results can be saved to the Windows Clipboard or to a file by the procedure below.
Some dialog boxes do NOT have a Copy to Clipboard or Save to Disk function. This duplicates that
functionality.
To save query results
1. Turn on spooled output to disk file: Database | Spool SQL | Spool SQL To File.
2. Run the desired Toad window (for example, the Schema Differences window) select each desired tab.
3. From the User Files folder, open DEBUG.SQL.
4. Copy each SQL into the Editor window.
5. Run each SQL in the Editor window, substituting hard coded values for the bind parameter variables, or
just enter them when prompted in the Variables dialog box.
6. Save the grid contents to clipboard or disk file, using right-click, Export Dataset.
Copy Statements between Toad and
Development Tools
The Editor window contains two functions that simplify copying SQL statements from Toad to code development
tools such as Delphi, Visual Basic (VB), C++, Java, or Perl, and from those code development tools back to
Toad. These functions are available from the Editor File toolbar or by using keyboard shortcuts.
Strip Code Statement (CTRL+P)
Toad 12.11 Getting Started
Work with Code
92
Make Code Statement (CTRL+M)
Strip Code Statement
The Strip Code Statement function strips off the code development tool syntax from the SQL statement, ready to
execute in Toad.
For example, if you take the following Visual Basic code from the Visual Basic development tool, copy it, paste it
into Toad, and run Strip Code Statement, it changes the SQL statement from this:
Sql = " select count(*) as cnt"
Sql = Sql & " from all_tables"
Sql = Sql & " where owner = 'DEMO'"
Sql = Sql & " and table_name = 'EMPLOYEE'"
to this:
select count(*) as cnt
from all_tables
where owner = 'DEMO'
and table_name = 'EMPLOYEE'
Now the SQL is ready to execute in Toad.
If you have multiple SQL statements in the Editor, highlight the statement you want to strip before executing the
Strip Code Statement function.
Make Code Statement
The Make Code Statement function adds the code development tool syntax to the SQL statement in the Editor
and makes it ready to paste into the appropriate development tool.
When making code statements, rather than changing the code in the Editor window as the Strip Code Statement
function does, the Make Code Statement function takes the currently highlighted SQL statement, translates it
into the code development tool syntax, and copies it to the clipboard. You can now switch to the code
development tool and paste in the results. A message displays in the status panel such as VB statement was
copied to the clipboard.
If you have multiple SQL statements in the Editor, highlight the statement you want to make before executing the
Make Code Statement function.
Note: You can access these same options via the toolbar. The button to the right of the two buttons for Make...
and Strip VB code statement from SQL lets you perform your latest selection with one click; it remembers your
most recent selection from the list via the drop-down arrow.
How to Select the Code Development Tool
The default selection is Visual Basic. Click the arrow beside either button on the Editor toolbar to change the
default selection.
You can also select the code development tool in the View | Toad Options | Editor | Code Assist |
Make Code box.
Toad 12.11 Getting Started
Work with Code
93
The Make Code Format box lets you select a language syntax for Toad to convert a SQL statement into (Make
Code Statement function) and out of (Strip Code Statement function). Currently, Delphi, Visual Basic, C++, Java
and Perl are supported.
See Code Assist Options in the online help for more information.
You can also create your own language templates.
Create Templates for Make Code Statement Functions
View Code Statistics
Toad can provide you with some basic statistics about your code.
Note: Because of the way the parser counts lines, the number of lines of code and blank or comment lines may
vary. Use these statistics as an estimate rather than an exact count.
To view formatting statistics
1. Open the code in the Editor.
2. Right-click and select Formatting Tools | Profile Code.
Work with the Query Builder
Query Builder Overview
The Query Builder window provides a fast means for creating the framework of a Select, Insert, Update, or
Delete statement. You can select Tables, Views, or Synonyms, join columns, select columns, and create the
desired type of statement.
To access the Query Builder
Click
on the main toolbar.
Note: You can also select Database | Report| Query Builder.
Area
Description
Query Builder workspace
tabs
Use the Query Builder workspace tabs (the Model Area) to graphically lay
out a query.
Tree View
The pane on the left displays the current query in tree view.
Generated Query Tab
Automatically generated SQL as a result of the diagram displayed in the
Query Builder workspace. The Query Results tab displays the results of the
created query. The Messages tab displays warnings regarding the query.
Click on the error to highlight the related object.
The Generated Query content is editable.
When the diagram and the generated query no longer match, these buttons
Toad 12.11 Getting Started
Work with Code
94
Area
Description
become available on the Query Results toolbar:
- Update Diagram
- Update SQL
Text also indicates, "Diagram and SQL Code are Not Synchronized. Click
Here or Press Ctrl +SHIFT +D to Synchronize.
To navigate the Query Builder
Click on items or use the keyboard:
l
Up and down arrow keys move you around in lists
l
SPACE checks and clears boxes
l
TAB moves forward one area (table, menu, list, etc)
l
SHIFT+TAB moves back one area.
To set Query Builder Options
Select View | Toad Options | Query Builder.
Press F1 for information about the options.
To get more information about building queries
See the Build Queries section of the Table of Contents in the online help.
How to use the Model Area
On the Query Builder tab, click
to open an INLINEVIEW tab.
Pages are numbered with column/row combinations:
[1,1]
[2,1]
[1,2]
[2,2]
Nested and in-select subquery links are represented as follows:
l
l
Subqueries by a dashed line.
Union queries by a symbol that represents the type of union. Double-click the line to change the
type of union.
Use the Query Builder workspace to visually join or manipulate the Tables, Views, or Synonyms. You can click
in a table header and drag the table to anywhere in the model area.
To specify columns for the query
Click in the checkbox for each desired column. A checkmark will be displayed in the box. The selected column's
information will display in the navigation tree, and the column will be included in the query.
Note: If no table columns are selected, then all columns will be included in the query.
Toad 12.11 Getting Started
Work with Code
95
To establish your own joins
Drag a column from one table to another table column. When the line is drawn, you can double-click the line to
adjust its properties such as Inner Join vs. Outer Join, or Join Test. For example, equal (=), less than (<), greater
than (>), and so on.
To view joins
Double-click a join line in the Model Area.
To describe a table
You can use the F4 key to describe a selected table. If a table is not selected when you press F4, the last
selected table will be described. Describe Objects
Build a Query
Follow this procedure to get started using the Query Builder.
To build a query
1. Drag-and-drop Tables, Views, or Synonyms from the Schema Browser, Project Manager, Object
Palette, or the Object Search window to the Query Builder workspace tab.
2. Click in the checkbox by a column to add it or remove it from the active query's SELECT clause.
3. Drag-and-drop columns from one table to another to create joins between the tables.
4. Add any WHERE, GROUP BY, HAVING, or ORDER BY clauses by right-clicking on the column and
selecting Include in n clause. Right-click and adjust properties for clauses where necessary.
5. To create a new clause, drag-and-drop columns from a table to WHERE, GROUP BY, HAVING or
ORDER BY in the Query Browser tree node.
6. Click
on the toolbar to save the model to disk.
7. Click the Generated Query tab to view or edit the generated query.
a. If you update the diagram and the SQL code is not synchronized, click
Query toolbar to update the code.
b. If you update the code, click
in the Generated
in the Generated Query toolbar to updated the diagram.
See also Create a Subquery
Create a Subquery
You can easily create a subquery or nested subquery. Subqueries can be created from the FROM clause or the
WHERE clause.
Columns must be dragged directly from the table area to be placed in subqueries, or from the current statement.
After initiating the subquery using one of the methods below, create the subquery as you would a normal query.
Toad 12.11 Getting Started
Work with Code
96
To create a subquery in the WHERE clause
1. Drag a column into the WHERE node.
2. In the Condition dialog, use the simple or complex mode.
If you click Nested Subquery, the new subquery is created in the workspace.
To create an EXISTS subquery
1. Right-click the WHERE clause in the tree view.
2. Select Add EXISTS Subquery or Add NOT EXISTS Subquery.
To create a subquery in the FROM node
1. Right-click the FROM clause in the tree view.
2. Select Add | New Named Subquery (or New Inline View).
Populate the Where Clause
There are two ways to populate the WHERE clause in SQL generated by the Query Builder: as an individual
WHERE, or as a global WHERE.
To populate the where clause
1. Do one of the following:
l
Right-click on the column under the SELECT node and select Include in Where Clause.
l
Drag a column from the select node to the WHERE node.
Add conditions and select or clear any outer joins you want to apply.
Note: To build a more advanced query, click the Expert tab and enter your code by typing it in the top
box or double clicking on functions and data fields to enter them.
2. Click OK.
Repeat until all conditions are added.
Note: When you add multiple columns to a WHERE clause, they are automatically placed
3. If a condition should be an OR condition, rather than an AND, right-click on it and select OR.
To create a global WHERE clause
1. Right-click in the Table Model area.
2. Select SQL | Global Where Clauses.
3. Click
.
4. Enter or build your condition.
5. Click OK to close the definition window.
6. Click OK.
Example
To construct the following query:
Toad 12.11 Getting Started
Work with Code
97
SELECT DEPT.DEPTNO, DEPT.DNAME, DEPT.LOC
FROM DEPT
WHERE (((UPPER (RTRIM (DNAME)) = 'SALES') AND (DEPT.DEPTNO < 40)) AND ((DEPT.LOC =
'CHICAGO')OR ((DEPT.LOC IS NULL = '')))
Do the following:
1. Open the Query Builder.
2. In the Object Palette, select the Scott schema and double-click the DEPT table to add it to the model.
3. Right-click DEPT and choose Select All.
4. Drag the DEPTNO column to the WHERE node.
5. Select < in the operator box, click Constant, and enter 40 in the condition box.
6. Click OK.
7. Drag the LOC column to the WHERE node.
8. In the WHERE definition dialog, click the Expert tab. Click OK to confirm.
9. Double-click IS NULL in the SQL Operators area and then click OK.
10. Drag the DEPTNO above LOC in the tree view.
11. Right-click the LOC column and select OR.
12. Right-click on OR | LOC and select Properties. Select = in the operator box, click Constant, and enter
CHICAGO in the condition box.
13. Click OK.
14. In the table model area (the area around the table images), right-click and choose SQL | Global
Where. Click
.
15. In the top edit box, enter (UPPER (RTRIM (DNAME))) = 'SALES'.
16. Click OK and then click OK again.
View the generated query. It should display as described above.
You can automatically populate the Having clause in the SQL generated by the Query Builder in one
of two ways.
Note: To create a HAVING clause, you must have added columns to the GROUP BY node.
HAVING entries should be in the form of <expression1> <operator> <expression2>.
To populate the HAVING clause
1. Do one of the following:
l
Right-click the desired column in the tree, and then select Include in Having Clause.
l
Drag a column from a table in the Table Model area to the HAVING clause.
2. Enter or build the condition.
3. Click OK.
4. Repeat until complete.
Global HAVING clauses
In order to include a global HAVING clause, there must be a GROUP BY clause as well.
Toad 12.11 Getting Started
Work with Code
98
To create a global HAVING clause
1. Right-click in the Table Model area.
2. Select SQL | Global Having.
3. Click the Add button.
4. Enter or build your condition.
5. Click OK to close the definition window.
6. Click OK.
Example
To construct the following query:
SELECT emp.empno, emp.ename, emp.job, emp.mgr, emp.sal,
emp.comm, emp.deptno
FROM emp
GROUP BY emp.deptno, emp.comm, emp.sal, emp.mgr, emp.job,
emp.ename, emp.empno
HAVING ((emp.sal + NVL (emp.comm, 0)> 4000))
Do the following:
1. Open the Query Builder.
2. In the Object Palette, select the Scott schema.
3. Double-click the EMP table to add it to the model.
4. Right-click EMP and choose Select All, then clear Hiredate.
5. Drag DEPTNO, COMM, SAL, MGR, JOB, ENAME and EMPNO to the Group by node.
6. Right-click in the Table model area and select SQL | Global Having. Click
Having clause.
to add a new Global
Enter the Having clause to say:
EMP.SAL + NVL(EMP.COMM, 0) > 4000
7. Click OK twice.
View the generated query. It should display as described above. This query selects all the employees whose
salary plus commission is greater than 4000.
The NVL command substitutes a null value in the specified column with the specified value, in this case, 0.
Use a Generated Query
The Generated Query tab shows the SQL statement that is automatically generated when you work on your
query. Any changes made to the model or column criteria will automatically regenerate this SQL statement.
To copy the query to the clipboard
Do one of the following:
l
Select a query and press CTRL+C
Toad 12.11 Getting Started
Work with Code
99
l
Click the Send text to clipboard button
l
Select the query, right-click and select Copy
To send the query to the Editor
Click
in the Generated Query toolbar.
To execute the query
1. Click
(Execute Query).
2. View the results on the Query Results tab.
Generate ANSI Syntax
You can convert a SQL statement to ANSI from the Generated Query tab of the Query Browser, or you can set
Toad to convert it automatically.
To convert a SQL statement from the Query Builder
In the Generated Query tab, select the query to convert and click the ANSI join syntax button.
To create ANSI syntax automatically
Select Toad Options | Query Builder.
Press F1 to view information about the options.
Tune the query
From the Generated Query tab you can select tuning options for your current query.
To tune the query
1. Click the arrow next to the
(Optimize) drop-down.
2. Select a tuning method.
Note: Advanced SQL Optimization requires the SQL Optimizer module.
This feature is available in the Xpert Edition and higher.
3. Press F1 for information about the selected method.
Save Query Results
Any of Toad's window query results can be saved to the Windows Clipboard or to a file by the procedure below.
Some dialog boxes do NOT have a Copy to Clipboard or Save to Disk function. This duplicates that
functionality.
Toad 12.11 Getting Started
Work with Code
100
To save query results
1. Turn on spooled output to disk file: Database | Spool SQL | Spool SQL To File.
2. Run the desired Toad window (for example, the Schema Differences window) select each desired tab.
3. From the User Files folder, open DEBUG.SQL.
4. Copy each SQL into the Editor window.
5. Run each SQL in the Editor window, substituting hard coded values for the bind parameter variables, or
just enter them when prompted in the Variables dialog box.
6. Save the grid contents to clipboard or disk file, using right-click, Export Dataset.
Execute Statements and Scripts
About Executing Scripts
Toad provides many different options for you to execute scripts:
If you want to...
Review the following:
Execute a script
in the Editor
Use Execute as script (F5) in the Editor. Execute Scripts in the Editor
Considerations:
l
l
l
Execute a longrunning script
without tying up
Toad (execute a
script outside of
Toad)
Does not support bind variables and cannot produce editable data.
Alternately, you can execute the code as a statement. Execute Single
Statements
Fetches all matching records at the same time, which may cause it to execute
slower and use more resources.
Use Toad Script Runner for scripts that may take a long time to execute or to execute
a script in an external application.
See Execute Scripts with Toad Script Runner in the online help for more information.
Considerations:
l
l
Execute multiple
scripts
Long-running scripts can tie up the Editor.
Compared to executing a script in Toad, Toad Script Runner does not offer all
of the Editor's features
You can also use SQL*Plus to externally execute scripts. SQL*Plus does not
have data grids or other Toad features, and it does not support Unicode.
Execute SQL with SQL*PlusExecute SQL with SQL*Plus
You can use the Automation Designer or Script Manager. See the following in the
online help for more information:
l
Automation Designer Overview
l
Script Manager Overview
Toad 12.11 Getting Started
Work with Code
101
If you want to...
Review the following:
Schedule
execution
Create a Toad Action and schedule it to run.
Execute through
the command line
Execute scripts or Toad Actions with scripts from the command line. See the following
in the online help for more information:
See Schedule Actions and Apps in the online help for more information.
l
Command Line Syntax
l
Execute Actions from the Command Line
l
Automation Designer Overview
Execute Single Statements
You can easily execute a single statement in the Editor. Toad's parser identifies and executes the statement or
compiles the PL/SQL at the cursor.
Note: If you select code and execute, Toad ignores the parser results and executes the portion that is selected.
This may cause errors, especially if you select more than one statement. It is better to place your cursor in the
statement you want to execute and let Toad select the statement.
This method fetches matching records in batches to improve performance.
To execute a statement in the Editor
Place the cursor in the statement and click
Note: To cancel the execution, click
on the Execute toolbar (F9).
in the Execute toolbar.
Execute Scripts in the Editor
Toad's Execute as script command is generally the best method when you want to execute multiple statements
or a script in the Editor. However, there are some important differences between executing scripts and a single
statement. For example, executing scripts:
l
Does not support bind variables
l
Cannot produce editable datasets
l
Fetches all matching records at the same time, which may cause it to execute slower and use more
resources than executing a single statement
Execute long-running scripts
If you want to execute a script that may take a long time to run, executing with Toad Script Runner may be the
best choice. Toad Script Runner is an external execution utility, which allows you to keep working in Toad while
the script executes in the background.
See Execute Scripts with Toad Script Runner in the online help for more information.
Notes:
Toad 12.11 Getting Started
Work with Code
102
l
l
l
Toad does not support all SQL*Plus commands. See the online help for more information.
Linesize in Toad defaults to 80, just as in SQL*Plus. If you want to change this to a longer amount, you
can do it using the SET LINESIZE command in your script.
To load and immediately execute a script file, select Editor | Load and Execute a Script File.
To execute the contents of the Editor as a script
Click
on the Execute toolbar (F5).
Caution: If any changes have been made, the script in the current window is automatically saved,
and then executed as a script.
Note: To cancel the execution, click
in the Execute toolbar.
Execute scripts with the @ command
When you run something containing the @ command (such as @whereami.sql) as script in the Editor, Toad
follows a hierarchy of where to look for the whereami.sql file to execute.
The hierarchy it follows is:
1. Parent script directory (If you load scripta.sql that has an @scriptb.sql command in it, Toad first looks in
the directory where scripta.sql is located.
2. Current Editor directory (File | Open in Editor).
3. Toad dir/User Files.
4. SQLPATH environmental variable.
Execute SQL with SQL*Plus
You can open a DOS box to execute the contents of the Editor using SQL*Plus.
Important:
SQL*Plus does not support Unicode.
Toad does not support all SQL*Plus commands. See SQL*Plus Commands in the online help for more
information.
Note: If you change data in the script session, the changes will not reflect in Toad until you commit the changes
in the script session. Also, any session control statements executed in the script session (such as
ALTER SESSION) are not visible to the Toad session.
To access MS DOS for SQL*Plus
From the Editor menu, select Execute SQL via SQL*Plus.
Toad 12.11 Getting Started
Work with Code
103
Save Statements (SQL Recall)
Save and Reuse SQL Statements
Through SQL Recall, you can save any SQL statement to your Toad environment so that it can be reused. If
statements are not saved, they are eventually discarded as new statements are executed and added to the list.
To view the SQL Recall pane
From the main Toad menu bar, select View | SQL Recall (F8).
l
Recently executed statements are stored on the Recent pane.
l
Saved statements are stored on the Saved panel of SQL Recall.
Statements can be saved in two ways:
l
l
Unnamed: When you save a statement without a name, it is saved to the Saved tab with a Toadassigned name of Statement (n), where n is a number that increments by one for each new
saved statement.
Named: The best way to save SQL statements is to save them as Named SQL. When a statement has a
name, you can:
l
easily access it in the Editor.
l
easily determine what it does, rather than having to read through the code.
Statements are saved under categories. Categories enable you to organize your statements, for example by
application or type of data. Toad provides a Default category which contains any statements not placed in a
specific named category.
To save a statement without naming it
1. In the Recent pane of SQL Recall, select the statement or statements that you want to save.
2. Right click and then select Add to Saved.
3. Select a category or specify a new one, and then click OK. The statement is saved to that category on the
Saved tab.
To save a SQL statement as Named SQL
1. Do one of the following, depending on where the statement is displayed:
Editor: In the Toad toolbar, select Editor | Add to Saved SQLs.
SQL Recall: If the statement is still in the Recent tab, click Add to Saved to move it to the Saved tab.
Once a statement is on the Saved tab, right-click the statement, then select Properties.
2. Select a category or specify a new one.
3. Provide a name in the Name field. Note: The name is case sensitive. For example, you can save both
sql1 and SQL1.
4. Select a schema for the saved SQL.
5. Select the database that contains the specified schema.
6. Click OK.
Toad 12.11 Getting Started
Work with Code
104
To open a Named SQL statement in the Editor
1. Select one of the following options:
l
l
l
Press CTRL+N in the Editor and select the statement from the pick list.
Enter MyNamedSQL in the Editor, where MyNamedSQL is the name of your saved SQL
statement. Toad replaces the SQL name with the saved statement at execution.
Double-click or drag the statement from the SQL Recall pane.
Execute a saved SQL statement
Once a saved SQL statement (named or unnamed) is open in the Editor, you can:
l
l
Execute it from the Editor. Execute Single Statements
Execute it from the Connection Panel of the Project Manager. See the online help for more information
about Project Manager.
Export or import a saved SQL statement
Toad allows you to export and import saved SQL. Import/Export Saved SQL.
Import/Export Saved SQL
You can export your saved SQL from SQL Recall for use by others, and you can import saved SQL into your
own Toad environment.
You can export your recent statements, your saved statements, or both, or you can select specific categories or
statements to export.
Note: This feature was introduced in Toad 11, and consequently you can only import these files with Toad 11
and later versions.
To export saved SQL
1. Select View | SQL Recall (F8).
2. If you want to export specific statements, select them.
3. Click
on the SQL Recall toolbar.
Tip: You may need to expand the SQL Recall pane to see the button.
4. Under Statements, select the types of statements to export*:
All: export all statements from Recent and Saved tabs.
Recent: export only the statements on the Recent tab.
Saved: export only the statements on the Saved tab.
Selected: export only the statements that you explicitly select.
Toad 12.11 Getting Started
Work with Code
105
5. Under Format, select the output format:
SQL Recall data file: Save as the file type used by Toad to store recent and saved statements.
Single File: Save as a single text-based file.
Individual Files: One file for each Saved category and one for all Recent statements: Save one file
for each Saved category and save all Recent statements in one file. (Whether these outputs will be
present depends on what you selected under Statements.) If you select this option, select an extension
under File Extension.
*Note: Recently executed statements are always stored in one file. Saved statements are stored either by
category name or by a user-defined name, depending on how you specified the export.
To import saved SQL
1. Click
on the SQL Recall toolbar.
Tip: You may need to expand the SQL Recall pane to see the button.
2. Select the saved SQL export file.
3. Select Append mode to add the imported SQL to your existing library of recent or saved statements, or
select Replace to replace the existing library of recent or saved statements with the contents of the
imported file. Important! A Replace cannot be undone, and your existing statements will be permanently
overwritten by the imported ones, including any category names.
4. Click OK.
Work with PL/SQL Objects
Load Database Object
Use the Load Database Object dialog to load an existing object into the Stored Edit/Compile window for
further editing.
To load an object from the database
1. Click
in the Editor window.
2. From the Schemas/Owners drop-down:
l
Enter the first letter of the schema to perform an incremental search of the list.
l
Select the Schema/Owner of the object you want to load
l
Select the type of object you want to load from the drop-down list.
l
l
For databases with few objects, just select All.
For databases with many objects, select a type of object and then filter to show a
manageable list in the left hand panel below.
3. From the left hand panel, you can do one of the following:
Toad 12.11 Getting Started
Work with Code
106
l
Click an object to select it.
l
Enter the first few letters of the object you want to perform an incremental search.
Note: You can turn the preview off by using the Show Source checkbox.
Reload Object
The reload object options give you an easy way to synchronize your PL/SQL source with objects also existing
on the database.
You can reload objects in one of several ways.
To reload an object from the Navigator
1. In the Navigator, select the object you want to reload.
2. Right-click and select Reload.
To reload all objects from the Navigator
1. In the Navigator, select the object you want to reload.
2. Right-click and select Reload All.
To reload from the Toolbar
1. Place your cursor in the object in the Editor that you want to reload.
2. Click
(Reload object from database) on the toolbar.
Create New PL/SQL Object
Use the Create New PL/SQL Object dialog to create a new database object. Toad opens a dialog that enables
you to specify the parameters for the CREATE statement and allows you to select a default or custom template
to speed the creation of the object.
To create a new PL/SQL Object in the Editor
on the Editor toolbar. (If this button does not display, you may need to add it.
1. Click
Show/Hide Toolbars
2. Select the type of object you want to create.
3. Enter the name of your new object in the New Object Name box, or leave this blank for now and enter a
name when you save the object.
4. Select a template.
To create a new PL/SQL Object from the Schema Browser
1. In the schema browser object type drop-down, select the object type that you want to create (package,
procedure, function, and so on).
Toad 12.11 Getting Started
Work with Code
107
2. Click . The button is context-sensitive based on your object type selection and launches the
appropriate dialog.
3. Provide the information and select a template.
Default Templates
The following default templates are stored in the Toad for Oracle\User Files folder:
NEWPROC.SQL
Create a Procedure
NEWFUNC.SQL
Create a Function
NEWPackage.SQL
Create a Package spec
NEWPackageBody.SQL
Create a Package body
NEWType.SQL
Create a Type spec
NEWTypeBody.SQL
Create a Type body
NEWTrigger.SQL
Create a Trigger spec
In addition, there are two template types that you can use only within packages. These are Package Function
and Package Procedure. See Use Templates within Packages in the online help for more information.
Custom Templates
You can use a text editor to create new templates and edit the default templates. The new or revised template
will be shown in the template selection drop-down when you create a new object.
To create a custom template
1. Select Toad Options | Proc Templates from the Toad menu.
2. See Procedure Template Options in the online help for more information.
Keyword substitutions in templates
There are several keywords in the templates for which Toad will automatically substitute in values when you
open the templates.
%YourObjectName% Object Name
%SYSDATE% Workstation date, for example, mm/dd/yyyy
%DATETIME% Workstation date and time, for example, mm/dd/yyyy hh:mm:ss am
%DATE% Workstation date, for example, mm/dd/yyyy
%TIME% Workstation time, for example, hh:mm:ss am
%USERNAME% Username specified in Toad Options, Editor node
%TRIGGEROPTS% Trigger Options for triggers only, for example, "Before insert on, for each row"
Note:
Toad 12.11 Getting Started
Work with Code
108
l
*YourObjectName* is also supported for backwards compatibility.
l
The keywords ARE NOT case sensitive.
l
The date and time formats come from the Windows Control Panel settings.
l
This feature is only in the Commercial version of Toad, not the freeware Toad.
In addition to these, you can specify custom keywords before you create the object. See Procedure Template
Options in the online help for more information.
Extract Procedures
You can extract a procedure from existing code into a new stored procedure or locally defined procedure.
Creating the new procedure and call depend heavily on the parser to determine which identifiers in the text
selection must be declared as parameters in the new procedure. If Toad cannot parse the code, no
extraction occurs.
To extract procedures
1. Select the code you want to extract in the Editor.
2. Right-click and select Refactor | Extract Procedure.
3. Select a procedure type.
Note: If you select stored procedure, you can choose to either include the CREATE OR REPLACE in the
DDL instead of just CREATE.
4. Enter the procedure name.
Tip: The new procedure and the resulting procedure call are created an inserted so that the code is
syntactically correct, but no formatting is done to the code. You can have Toad format the code by
pressing SHIFT+CTRL+F.
Generate DBMS Output
Oracle provides a package, called DBMS_OUTPUT, which is specifically designed with functions for debugging
PL/SQL code. It uses a buffer that your PL/SQL code writes into, and then a separate process queries the buffer
out and displays the contents.
The Editor has a Right-Click menu option that will generate a DBMS_OUTPUT statement for a highlighted
variable. The same menu has an option to create a blank DBMS_OUTPUT statement.
To generate an output line from a variable
1. Highlight the variable in the Editor.
Right-click and select Output Statements | Make Output Statement.
Note: The statement is created on the clipboard.
2. Paste the statement in your code where you want it.
Toad 12.11 Getting Started
Work with Code
109
To generate a blank output statement
1. In the Editor, right click and select Output Statements | Blank Output Statement.
2. Paste the statement in your code.
To view DBMS Output
On the main toolbar, select View | DBMS Output.
DBMS_OUTPUT results only display after the procedure has completed execution, not while you are single
stepping through the code. In nested procedure calls, all procedures must have run to completion before any
DBMS Output content is displayed.
Execute SQL Statements within PL/SQL
You can easily execute a SQL statement embedded within PL/SQL. Toad extracts the SQL statement and
adjusts the syntax as necessary. Any identifier which is not a column of a referenced object is treated as a
bind variable. If the identifier is a reference to a PL/SQL constant, the bind variable value defaults to the
constant value.
To execute a SQL statement within PL/SQL
Place the cursor in the statement and press SHIFT+F9. A new window displays with the extracted
SQL statement.
Execute PL/SQL
You can execute stored procedures, functions, packages or triggers in the Schema Browser or in the Editor.
To execute stored code from the Schema Browser
1. Click
on the Standard toolbar to open the Schema Browser.
2. Select a PL/SQL object then click
.
To execute stored code from the Editor
1. Click
on the Standard toolbar to open the Editor.
2. Open a PL/SQL object.
3. Click
or
on the toolbar.
Debug
About Debugging
You can debug PL/SQL and SQL scripts in Toad.
Toad 12.11 Getting Started
Work with Code
110
Notes:
l
l
l
There are minimum Oracle database requirements for using this feature. Minimum Oracle Requirements
for Debugging
The debugger is not designed to work with word-wrapped lines, since the Editor will then have a
different set of line numbers than what is stored in Oracle. Toad provides a warning message about this
if you open the procedure Editor while word-wrapping is enabled. To disable word-wrap, select View
| Toad Options | Editor | Behavior and clear Word wrap.
To avoid modifications to code that is being debugged, Toad does not allow you to run a query while you
are running a debugging session.
Types of Debugging
Toad provides the following debug features:
DBMS
Debugger
Debugs PL/SQL. Using the Debugger, you can set breakpoints, watches, and see call stacks.
In addition, you can view DBMS output.
Note: When using the PL/SQL Debugger and connecting to a RAC instance, you must have
the TNSNAMES entry for the instance with the server directed the use connection or session
here. Or, you must connect directly to an instance of the cluster without letting the server
assign an instance.
Script
Debugger
Debugs SQL scripts. You can set breakpoints, run to cursor, step over, trace into, and halt
execution of your scripts.
Attach
External
Session
External debugging allows you to debug PL/SQL that is run from an external session, such
as another Toad window, SQL*Plus, or any other development tool which calls Oracle stored
procedures.
Debugging in Toad requires you to select one type of debugging at a time for all database instances open per
instance of Toad. For example, if you have three database connections in one instance of Toad, they must all be
in the same debugging state. If you then opened another instance of Toad, with the same or different
connections, they could be in a different debugging state.
Compile with Debug Information
To use the debugger fully with PL/SQL or Java packages, you need to compile your object with debug
information. Start Debugging
In addition, if you are debugging an object that has dependent objects, you cannot step into the dependents
unless they, too, are compiled with debug information. Handle Dependencies and References
Compile without Debug Information
To reduce the size of your code when it is ready for production, you should compile without debug information.
Prepare PL/SQL Code for Production.
Toad 12.11 Getting Started
Work with Code
111
Get more information on Debugging
l
l
Toad's online help includes tutorials on how to debug. See Debugging a Procedure or Function Tutorial
in the online help for more information.
See the Debug section of the Table of Contents in the online help for additional topics on debugging.
Debug PL/SQL
Minimum Oracle Requirements for Debugging
For all databases, you must have the Oracle Probe API v2.0 or later installed in order to debug PL/SQL
using Toad.
To check the Oracle Probe API version
1. Make sure a package called DBMS_DEBUG exists in the SYS schema.
To find out what version of the Probe API you have, run the following anonymous PL/SQL block in the
SQL editor with a DBMS Output window tab selected:
declare
probe_major_ver varchar2(10);
probe_minor_ver varchar2(10);
begin
dbms_debug.probe_version(probe_major_ver, probe_minor_ver);
dbms_output.put_line('MAJOR='| | probe_major_ver);
dbms_output.put_line('MINOR='| | probe_minor_ver);
end;
If the DBMS Output window displays:
MAJOR=2
MINOR=2
Then the version of Oracle Probe API is 2.2.
Database Version Notes
For Oracle 10g and 11g, you must have the DEBUG CONNECT SESSION privilege, or Oracle will not let you
use DBMS_DEBUG.
Additional notes
l
You cannot use the Evaluate/Modify window to change argument values.
l
Watches on package variables are only allowed for Probe v2.2 or higher.
Start Debugging
You debug PL/SQL objects in the Editor.
Toad 12.11 Getting Started
Work with Code
112
When you open a complete package or type in the Editor, the spec and body open in separate tabs by default.
However, Toad provides options to control how objects are split, reassembled, and saved. See Editor
Open/Save Options in the online help for more information.
To use the debugger fully with PL/SQL or Java packages, you need to compile your object with debug
information. If you have not compiled with debug information, in databases in versions before 10g you can step
into a unit, step over and so on, but you cannot see watches unless the object is compiled with debug. In a 10g
or later database you cannot step into code or step over unless the object was compiled with debug. You can
only execute.
In addition, if you are debugging an object that has dependent objects, you cannot step into the dependents
unless they, too, are compiled with debug information.
To start debugging
1. Open a PL/SQL object in the Editor.
on the main toolbar or select Session | Toggle Compiling with Debug. This enables
2. Click
debugging.
3. Compile the object on the database.
4. Select one of the following options on the Execute toolbar to begin debugging:
l
Execute PL/SQL with debugger
l
Step over (
l
Step into (
l
Run to cursor (
.
)
)
)
Set Parameters
Some PL/SQL has variable parameters that need to be set before you can run the code. If values for these
variables are not set, an Oracle error may display when you run the code.
Note: The values entered in the Set Parameters window are for the column values, not the argument values of
triggers. Set Parameters in Triggers
Toad 12.11 Getting Started
Work with Code
113
To set parameters
1. Select Debug | Set Parameters.
2. Enter any necessary values in the Arguments grid.
Notes: When the input type is set to Expression, anything in the Value column is used as-is in the
anonymous block. This is useful for setting input value to, for example, the return value of a function
or a SELECT statement.
In the case of a SELECT statement, Toad detects that it is a SELECT statement and inserts the
required INTO clause into the anonymous block. The SELECT must return a single value (single row,
single column), such as the count number in the following example, because the code is initializing
one variable.
Example input expression:
SELECT COUNT (*) FROM user_objects WHERE object_name LIKE 'EMP_TEST_%'
How it translates to input in the anonymous block:
SELECT COUNT (*)
INTO var_P1
FROM user_objects
WHERE object_name LIKE 'EMP_TEST_%' ;
Expression and Null are mutually exclusive. If neither of those columns are selected, the value is
treated as a literal.
3. Select the Output Options tab to specify how you want output displayed. Review the following for
additional information:
PL/SQL Results
Select one of the following...
Print OUT
arguments/RETURN values
to DBMS Output
Select this option to send the results to the DBMS Output window.
Fetch Cursor Data
Select this option to load REF CURSORS output into memory.
NOTE: To be able to view the cursor data after execution, this
option must be selected.
Print to DBMS Output
(char/number columns
only)
Select to fetch data from the REF CURSOR and print it to DBMS
output one row per line. You can also select the following options:
l
l
Fixed column width (characters)—Select to modify the
generated code to apply the Oracle RPAD() function to all
values printed to DBMS output, passing the user-specified
width. This will not only right-pad values with spaces, but
also truncate values longer than the given width.
Row fetch limit per cursor—Limits the number of rows
fetched. Applies to both DBMS output and table options.
Note: Toad raises an exception if a line is more than 255 characters
long. This option will only print values of char/number datatypes.
For other datatypes, the name of the datatype is printed in square
Toad 12.11 Getting Started
Work with Code
114
brackets.
4. To rebuild the code and see the variables, click
the anonymous block will be lost.
. Important! This rebuilds the code and all changes to
5. Set Profiler parameters as needed. Use a PL/SQL Profiler
Set Parameters in Triggers
When a trigger is executed, a preprogrammed operation occurs on a table. You’ll notice that debugging triggers
is different from debugging procedures or functions. First, the values entered in the Set Parameters window are
for the column values, not the argument values. Set Parameters
Before you can run a trigger, you have to set the parameters for that trigger. Each type of trigger has a different
set of parameters that are required.
Note: When you have entered a value into the Value column of the grid, if you want to make it NULL again, type
NULL. If you simply delete the value, the value will revert to an empty string.
INSERT
When you are debugging an INSERT trigger, the values you enter are used as the values to be inserted. The
record you insert is then rolled back so that no changes are made to the database during debugging.
To debug an insert trigger
In the Value field, enter a value to be inserted.
Note: The INSERT INTO… code is not valid until you enter column values.
UPDATE
Enter values for the SET… clause AND the WHERE… clause. The UPDATE TABLE… code is not valid until you
enter the column values.
To debug an update trigger
1. In the Value field, enter values for the SET… clause.
2. In the WHERE value field, enter values for the WHERE… clause.
Note: The updated record will be rolled back so that no changes are made to the database during
debugging.
DELETE
When debugging a DELETE trigger, you must enter values for the WHERE… clause.
To debug a delete trigger
Enter the WHERE… values in the Value field. The DELETE FROM… code is not valid until the column values
are entered.
Multiple Trigger Priorities
In the case of multiple BEFORE or AFTER actions, trigger types take priority and will be performed as follows:
Toad 12.11 Getting Started
Work with Code
115
l
INSERT
l
UPDATE
l
DELETE
Handle Dependencies and References
You can use the Debugger to check for dependencies, and compile them.
Manually compiling dependent & referenced objects
To compile dependencies manually
Click
or its drop-down on the debug toolbar and select the appropriate option.
Automatically Compiling Dependent Objects
Toad can automatically compile any procedures that call the current procedure.
To set options to handle dependent objects
1. From the View menu, select Options.
2. In the left pane, select Debugger.
3. In the Compile Dependencies area, select one of the following:
l
Yes - Toad will always compile dependencies.
l
No - Toad will never compile dependencies.
l
Prompt - Toad will check for dependencies and ask if you want to compile them.
See Debugger Options in the online help for more information.
Viewing Dependencies and their Status
You can visually view dependencies and their status.
To view dependencies and references
1. From the Schema Browser, objects panel, click the Procedures, Functions, or Packages tab.
2. Select the procedure you are debugging, then in the details pane, click the Deps(uses) and Deps (used
by) tabs. Status of the procedure is listed in the Status column in the details pane as valid or invalid.
Display PL/SQL as it is Called
The Call Stack window displays the chain of functions and procedures as they are called, in the order they are
called, with the most recent function or procedure listed on the top.
At the end of each procedure name is the current line number in that procedure. So, if you step into procedure B
from line 5 of procedure A, then the call stack will look like this:
Procedure B(1)
Procedure A(5)
Toad 12.11 Getting Started
Work with Code
116
To access the call stack
From the Desktops area, click the Call Stack tab.
To add the call stack tab to the Desktop
Right-click in the Desktops area and select Desktop Panels | Call Stack.
Stop the Debugger
If you are debugging a long procedure, you can stop the debugger while it is working.
To stop the Debugger while it is debugging
1. Click
.
The status panel will reset from Running to Idle.
2. When you have finished debugging your PL/SQL code, discard the debug symbol table: compile it again
by pressing F9.
Prepare PL/SQL Code for Production
When you have finished debugging your PL/SQL code, the debug symbol tables are left in the code. This makes
your code larger and can slow performance. To eliminate this issue, compile the code and its dependencies
and references one last time without debug information.
To compile without debug information
1. On the main toolbar, turn the debug toggle
button to the off position (not depressed).
2. Compile the code. This recompiles without the debug symbol tables.
View Debugging Results
Toad sends your PL/SQL debugger output results to the PL/SQL Results window. This window is located on a
tab in the output area of the Editor.
When the PL/SQL execution terminates, the PL/SQL Results window displays the input and output of the code,
in a format similar to that shown in the Set Parameters window (parameter name, data type, input, and output).
If there is a cursor result, you can view the data stored in each REF CURSOR that is returned via out parameters
or as a function result.
From this window, you can create and run unit tests and also open Code Tester for Oracle. Create and
Run Unit Tests
The PL/SQL Results window has the following limitations:
l
l
Works only with strongly-typed REF CURSORs.
Works only when the REF CURSOR type is declared in a package belonging to the currently
logged-in user.
Toad 12.11 Getting Started
Work with Code
117
To view cursor data
l
l
Before you execute the PL/SQL, select Fetch cursor data in the Set Parameters window. Set
Parameters
After you execute the PL/SQL, double-click (CURSOR) in the PL/SQL Results window.
To access the PL/SQL Results tab
If you cannot see the PL/SQL Results window at the bottom of the Editor, try one the following:
l
In the Editor toolbar, select PL/SQL Results from the Desktop drop-down menu.
l
Right-click in the Editor window and then select Desktop | PL/SQL Results.
l
If PL/SQL Results is already active but still not visible, then you may need to resize or reposition the
docked windows to make it visible.
Use DBMS Output
Enable DBMS Output
Toad uses the Oracle-provided DBMS_OUTPUT package, which contains functions for debugging PL/SQL
code. When enabled, it uses a buffer that your PL/SQL code writes into and then a separate process queries the
buffer out and displays the contents.
When you are running debugging in the Editor and DBMS output is enabled, a DBMS Output tab automatically
displays the results of DBMS_OUTPUT.PUT_LINE() statements in the Editor. You can also edit the DBMS
Output content to make comments, delete specific lines of output, and so on. The standard copy, cut, and paste
keys also work in the DBMS Output box.
To view DBMS Output in the Editor, you must enable DBMS Output before executing PL/SQL. The output
displays after the procedure has completed execution, not while you are stepping through the code. In nested
procedure calls, all procedures must have run to completion before any DBMS Output content is displayed.
Note: Output only displays after the procedure has completed execution, not while you are single stepping
through the code. In the case of nested procedure calls, all procedures must have run to completion before any
DBMS Output content is displayed.
To enable or disable DBMS output
At the top of the DBMS Output window, click the Enable/Disable toggle button.
To generate DBMS Output
Generate DBMS Output
To automatically insert DBMS_OUTPUT statements
You can use Toad's Auto Debugger feature to automatically insert DBMS_OUTPUT statements where
applicable and remove them when done. See Automatically Insert DBMS_OUTPUT Statements (Auto
Debugger) in the online help for more information.
Troubleshooting
If you do not see DBMS Output, try the following suggestions:
l
Right-click the lower pane and select Desktop | DBMS Output.
l
Make sure the Toggle Output On/Off button is on ( ) in the DBMS Output tab.
Toad 12.11 Getting Started
Work with Code
118
l
l
Then, set the interval in the Polling Frequency box. If the toggle is on, Toad periodically scans for and
displays DBMS Output content.
Contact your Oracle DBA to make sure the DBMS_OUTPUT package is enabled on your database.
View DBMS Output
DBMS_OUTPUT results only display after the procedure has completed execution, not while you are single
stepping through the code. In nested procedure calls, all procedures must have run to completion before any
DBMS Output content is displayed.
To open the DBMS Output window
On the main toolbar, select View | DBMS Output.
Edit DBMS Output
You can edit the output display in the DBMS Output window. This allows you to note what you did to receive
the output.
For example, when debugging a procedure named MyProc that expects a single number parameter, you can
execute the procedure from an Editor window with the following statement:
begin MYPROC(1); end;
Prior to executing the above, you can document the call in the DBMS Output with a comment:
Calling MyProc with 1
Then turn DBMS Output ON and execute MyProc. The DBMS_OUTPUT statements will display after your notes
about the call.
Create and Run Unit Tests
After you run PL/SQL with debugging, you can create a unit test for the active object in the PL/SQL Results
window of the Editor. The test is created in the Code Tester for Oracle repository, which must exist in the
connected database.
You can also run tests in this window. Toad supports a subset of the Code Tester functionality for creating a new
test, but Toad provides a direct link to Code Tester if you need more advanced functionality.
To create and run tests, the following are required:
l
l
l
l
l
You must have a licensed and supported Code Tester for Oracle installed on your system. Version
2.7.0.1015 is required. Code Tester for Oracle is part of the Toad for Oracle Developer Edition.
There must be a Code Tester repository on the database to which you are connected from Toad, and the
Code Tester repository must be a version that is supported by the version of Toad that you are using.
The repository version must be 2.7.0.1015 or greater.
The feature is enabled only if there are results in the PL/SQL Results window.
A connection to the database that contains the object must be defined in Code Tester. The test is created
under the node for that object on the Tests panel in Code Tester.
To create a new test, all input and output values must be of a type supported by Code Tester.
Note: Code Tester does not have to be running to create or run tests in Toad.
Toad 12.11 Getting Started
Work with Code
119
To create a unit test in Code Tester
1. Click
(Execute PL/SQL with Debugger) in the Editor toolbar.
2. Select the PL/SQL Results tab then wait for the run to finish.
(Create Unit Test) in the PL/SQL Results window. The new button opens the Create
3. Click
Test dialog.
4. In the Create Test Case dialog, complete the test information. You can change values as needed.
Note: By default, you are prompted to create a new test definition when you create the test case.
If you cannot create a test, the Code Tester repository on the database is not a supported version or does not
exist. Select Attach to Existing to attach the test case to an existing definition.
To run a test from Toad
Click
(Execute Code Tester for Oracle tests...).
To open Code Tester
Click
on the PL/SQL Results toolbar or on the Code Tester Results dialog (after you run the test).
To add unit tests to Team Coding
You can include your unit tests in your Team Coding projects. This enables you to manage the revision history
of your tests in the same way that you manage the revisions of your other controlled objects. The user/schema
who created the tests in Toad must be included in (or added to) the Team Coding project for the tests to be
controlled. For more information, see Configure Team Projects.
Debug Scripts
Script Debugger Overview
The Script Debugger is an extension to the Editor that you can use to debug short scripts. Using the Script
Debugger, you can do the following in addition to standard Editor functions:
l
Set Breakpoints
l
Run to Cursor
l
Step Over
l
Trace Into
l
Halt Execution
Note: Standard source control fully integrates with the Script Debugger. However, you cannot use Team Coding
with the Script Debugger.
To use the Script debugger
From the View | Toad Options window, select Debug | Script Debugger.
Toad 12.11 Getting Started
Work with Code
120
To commit changes
Click
on the main toolbar. This will commit changes in both sessions.
View Script Output
After you run a script, Toad displays the output and maintains a running list of system variables and user
variables. This lets you keep track of what has been set.
Use the toolbar buttons to copy or print the output, and to save the output to a file or Excel spreadsheet.
Tab
Description
Output
Displays any output from the script you are running, such as errors, status of system
variables, and data in output format.
Errors
Displays errors. Click an error to go to the location in the script where the error occurred.
Double-click an error to jump to possible solutions.
Grids
Display the data selected by the script. One grid displays for every select statement.
History
Displays output for all the scripts run during this session, or until the history tab is cleared.
This tab is hidden by default, but can be turned on in the options.
See Execute and Compile Options in the online help for more information.
Environment
Displays user, system, and bound variables and their values for the script.
Set Breakpoints
About Breakpoints
Breakpoints are markers in your code where you want to stop execution during debugging. The breakpoints
window displays as a tab in the desktop panel beneath the main Editor window. If you cannot see the
Breakpoints tab, you may need to add it to your desktop.
From the Breakpoints window, you can easily work with your breakpoints. You can select from the toolbars on
the window itself, or you can use the right-click menu to access more functions.
To add the breakpoints tab to your desktop
Right click in the desktops area and select Desktop Panels | Breakpoints. The breakpoints tab displays.
To open the breakpoints window
In the desktop area, click the Breakpoints tab.
See the online help for more information about using Breakpoints.
Set a Breakpoint
You can set (add) a breakpoint from several places.
Toad 12.11 Getting Started
Work with Code
121
To set a breakpoint in the Editor
Do one of the following:
l
Single-click in the Editor gutter to set or reset a breakpoint.
l
Press SHIFT+F5 to set or reset a breakpoint on the current line in the Editor.
The breakpoint is indicated by a stop sign in the gutter.
Note: It is recommended that you set your gutter width to 35. To do this, from the Edit menu, select Editor
Options and then enter 35 in the gutter width field.
To set a breakpoint from the Breakpoints window
1. Click
on the toolbar (or double-click the breakpoint).
2. Fill in the appropriate information and click OK.
To set a breakpoint from the Breakpoints Tab
Press INSERT.
To set a breakpoint from the Debug Menu
1. Click in the line where you want the Breakpoint.
2. From the Debug menu, select Add Breakpoint at cursor.
See the online help for more information about Breakpoints.
Set Watches
About Watches
Toad supports watches on implicit and explicit variables, including some complex data types such as explicitly
and implicitly defined records, %ROWTYPE records, and cursors.
From the Watches window, you can easily work with your watches. You can select from the toolbars on the
window itself, or you can use the right-click menu to access more functions.
Note: You can also hover your mouse over a variable to check the value without formally setting a watch.
To access the Watches window
Click the Watches tab in the Output area.
Note: If the watches tab is not visible, right-click and select Desktop Panels | Watches.
You can right-click a watch and select Export Watches, in addition to other options.
See the online help for more information about using watches.
Add a Watch
To add a watch from the Editor
Note: If the Watches window was not open, you will need to open it to view watches.
Toad 12.11 Getting Started
Work with Code
122
1. Click a variable in the Editor.
2. Do one of the following:
l
Click
l
Right-click in the Editor, select Debug and then Add Watch at Cursor.
l
in the toolbar.
Press CTRL+F5 to add the variable at the cursor to the list of watches. The watch is added but the
Watch Properties dialog box does not display.
To add a watch from the Watches window
Right-click and select the Add Watch menu item.
To add a watch from the Debug Menu
1. Click in the variable you want to watch.
From the Debug menu, select Add Watch at cursor.
Note: If text is selected when Add Watch at Cursor is chosen, Toad sets the watch on the selected text. If
no text is selected it uses the text under the cursor. This change occurs so that if you have a
recordname.fieldname, you can highlight only recordname to set a watch on it. If you have an expression
like v_List(2), where v_List is a varray, then you can highlight the entire expression to put a watch on it.
Use Smart Watches
Toad can automatically watch every variable in the active procedure or function. If you step into a new tab, the
smart watches window refreshes with the values on the new tab.
Smart watches are disabled by default and display collapsed.
If the smart watch window contains cursors or records, the cursor/record is listed as a node and each individual
item as an entry underneath it. These are, by default, displayed collapsed. You can expand them by clicking the
+ sign beside the node.
To enable smart watches
In the Watches window, select the Enable Smart Watches checkbox. About Watches
Configure the Smart Watch window
By default, watches and smart watches are arranged side by side in the Watches desktop panel. You can
also flip the watch window to show watches over smart watches instead of watches next to smart watches
(the default).
To flip the watch panels
Click
.
Move Smart Watches to the Watch panel
Unlike standard watches, smart watches are not saved when you leave the window as they are created
dynamically from the code you are actively using. However, if you want a watch to persist when you move into a
different procedure or function, you can drag the watch from the smart watches panel to the watches panel. In
the case of a watch that contains multiple parts, you choose to drag the node, which will copy everything under
it, or only one of the items within the node.
Toad 12.11 Getting Started
Work with Code
123
To move a smart watch to the watch window
l
Do one of the following:
l
Drag the smart watch from the smart watches panel to the watches panel.
l
Select a watch, right click, select Add.
l
Select a Smart Watch, click the Add Watch button on the toolbar.
Analyze Code
About Code Analysis
Code Analysis is an automated code review and analysis tool. It enables individual developers, team leads, and
managers to ensure that the quality, performance, maintainability, and reliability of their code meets and
exceeds their best practice standards.
l
Code Analysis is available in the Editor, which ensures code quality from the beginning of the
development cycle. In the Editor, Code Analysis evaluates how well a developer's code adheres to
project coding standards and best practices by automatically highlighting errors and suggesting smarter
ways to build and test the code.
Analyze Code in the Editor
l
Toad also provides a dedicated Code Analysis window, where you can perform more detailed analysis,
evaluate multiple scripts at the same time, and view a detailed report of the analysis.
See Perform Detailed Code Analysis in the online help for more information.
l
You can also publish Code Analysis results to Toad Intelligence Central.
Notes:
l
This feature is available in the Professional Edition and higher.
l
This feature was named CodeXpert prior to Toad 11.
Rules and Rule Sets
Code Analysis compares code against a set of rules for best practices. These rules are stored in rule sets.
The Code Analysis rules and rule sets can be adjusted to suit the requirements of different projects. Regardless
of whether developers are responsible for their own code quality or if this needs to be managed centrally, Code
Analysis can be adapted to fit either need.
See Create or Edit Rule Sets in the online help for more information.
Code Analysis Metrics
Code Analysis uses a variety of metrics to evaluate code, including the following:
l
Computational Complexity (Halstead Volume)—Measures a program module's complexity directly
from source code, with emphasis on computational complexity. The measures were developed by the
Toad 12.11 Getting Started
Work with Code
124
late Maurice Halstead as a means of determining a quantitative measure of complexity directly from the
operators and operands in the module. Among the earliest software metrics, they are strong indicators of
code complexity. Because they are applied to code, they are most often used as a maintenance metric.
l
l
Cyclomatic Complexity (McCabe's)—Cyclomatic complexity is the most widely used member of a class
of static software metrics. It measures the number of linearly-independent paths through a program
module. This measure provides a single ordinal number that can be compared to the complexity of other
programs. It is independent of language and language format.
Maintainability Index (MI)—Quantitative measurement of an operational system's maintainability is
desirable both as an instantaneous measure and as a predictor of maintainability over time. This
measurement helps reduce or reverse a system's tendency toward what is known as code entropy or
degraded integrity, and to indicate when it becomes cheaper and/or less risky to rewrite the code than to
change it. Applying the MI measurement during software development can help reduce lifecycle costs.
The Code Analysis Report includes detailed descriptions of the code metrics and how they work.
See Perform Detailed Code Analysis in the online help for more information.
Get more information
See the online help for additional topics on Code Analysis.
Analyze Code in the Editor
By default, Code Analysis automatically checks the code in the Editor for rule violations and underlines them.
The default rule set is composed of the Top 20, which is a key set of rules compiled by Steven Feuerstein and
Bert Scalzo, Toad experts and authors of Toad and Oracle-related books, articles, and blogs.
Note: To turn off automatic Code Analysis in the Editor, clear the Check Code Analysis rules as you typefield
in the Code Analysis options.
To analyze code in the Editor
Click
in the Editor toolbar, or right-click and select Analyze | Analyze Code.
The Code Analysis Statistics window displays, and CRUD (create, read, update and delete)
information and rule violations display in the tabs below the Editor.
Note: You can also click
in the Code Analysis toolbar.
To describe rule violations
1. To view a brief description of the violation, hover over the blue line.
2. To view a detailed description of the violation, right-click the blue line and select Code Analysis
Violations | Explain Rule.
To change the rule set
Select a different rule set in the Code Analysis toolbar.
Toad 12.11 Getting Started
Work with Code
125
Optimize SQL
Optimization
Toad offers several features to help you optimize queries or view the performance statistics for the server.
Although Toad provides access to these statistics and/or Oracle utilities, this section describes only how to use
the features within Toad, not how to interpret the results.
For an excellent guide on SQL tuning, we suggest Oracle SQL - High Performance Tuning by Guy Harrison
available from Prentice Hall Press.
See the online help for more information about these features.
Feature
Description
Optimize Current
SQL
Use Auto Optimize SQL to quickly optimize a single SQL statement. Toad searches
for faster alternatives and allows you to compare them to the original statement and
each other.
SQL Optimizer
If you have a Toad Edition that includes the SQL Optimizer package, you can use it to
help you optimize your code.
Explain Plan
Explain Plan shows the path and order in which Oracle will process your statement.
By processing Explain Plan on variations of a statement, you can see how the
adjustments will affect the execution.
SQL Trace
SQL Trace is a server-side trace utility that displays CPU, IO requirements, and
resource usage for a statement. SQL Trace is a much more complete utility than Auto
Trace; however, viewing the results can be difficult because the output file is created
on the server.
Auto Trace
Auto Trace is a mini version of SQL Trace that displays quick results directly on the
client. In Toad, the results are displayed beneath the Editor window.
Optimizer Mode
You can set the optimizer mode for the current session. This will affect all queries
(including Toad's own) for the duration of the session or optimizer setting.
Note: Optimizer mode is not available in Oracle 10g databases. Therefore Toad
disables this option when it is connected to a 10g database.
Toad 12.11 Getting Started
Work with Code
126
Profile PL/SQL
About the Profilers
You can use the DBMS Profiler or the hierarchical profiler, depending on their availability in your
database version.
Hierarchical Profiler
The PL/SQL hierarchical profiler organizes data by subprogram calls, and stores the results in database tables
letting you create custom reports.
See Oracle's documentation for more information.
Information provided includes:
l
Number of calls to the subprogram
l
Time spent in the subprogram
l
Time spent in the subprogram and descendent subprograms
l
Detailed parent-child information
DBMS Profiler
The Probe Profiler API profiles existing PL/SQL applications and identifies performance bottlenecks. The
collected profiler (performance) data can be used for performance improvement efforts or for determining code
coverage for PL/SQL applications. Application developers can use code coverage data to focus their
incremental testing efforts.
The profiler API is implemented as a PL/SQL package, DBMS_PROFILER, that provides services for collecting
and persistently storing PL/SQL profiler data.
Caution: Statistics may not be collected properly if you are running the profiler on an Oracle server on a
Tru64 platform.
Improving application performance is an iterative process. Every iteration involves the following:
l
Exercising the application with one or more benchmark tests, with profiler data collection enabled.
l
Analyzing the profiler data, and identifying performance problems.
l
Fixing the problems.
To support this process, the PL/SQL profiler supports the notion of a run. A run involves executing specified SQL
commands through benchmark tests with profiler data collection enabled.
Collected Data
With the Probe Profiler API, you can generate profiling information for all named library units that are executed
in a session. The profiler gathers information at the PL/SQL virtual machine level that includes the total number
of times each line has been executed, the total amount of time that has been spent executing that line, and the
minimum and maximum times that have been spent on a particular execution of that line.
The profiling information is stored in database tables. This enables the ad-hoc querying on the data: It lets you
build customizable reports (summary reports, hottest lines, code coverage data, and so on) and analysis
capabilities.
Toad 12.11 Getting Started
Work with Code
127
Set Up the Profiler
This feature requires that certain objects exist on the server before you can use it. If they do not already exist,
Toad prompts you to create them when you click
.
Note: To remove the profiler objects, click the arrow next to
and select Remove Profiler.
Additional Requirements for the DBMS Profiler
You must have the SYS.DBMS_PROFILER package to use the DBMS profiler.
To install the package
1. Login to an Oracle database through Toad as SYS.
2. Load the Oracle home>\RDBMS\ADMIN\PROFLOAD.SQL script into the Editor.
3. Click
on the Execute toolbar (F5).
4. Make sure that GRANT EXECUTE on the DBMS_PROFILER package has been granted to PUBLIC or
to the users that will use the profiling feature.
Additional Requirements for the Hierarchical Profiler
To use the hierarchical profiler, you must enable it in the Toad options. Select View | Toad Options |
Execute/Compile and then select Use hierarchical profiler on Oracle 11g and newer.
You must also have the DBMS_HPROF package to use the hierarchical profiler, which is available in Oracle
11g and later.
To verify the package is installed
1. Login to Oracle through Toad as SYS.
2. Make sure that GRANT EXECUTE on the DBMS_HPROF package has been granted to PUBLIC or to
the users that will use the profiling feature.
Use a PL/SQL Profiler
To use the hierarchical profiler, you must enable it in the Toad options.
To enable the hierarchical profiler
Select View | Toad Options | Execute/Compile and then select Use hierarchical profiler on Oracle
11g and newer.
To use a profiler
1. Click
on the main Toad toolbar to turn on profiling.
Note: If the profiler is not set up, Toad notifies you. Set Up the Profiler
Toad 12.11 Getting Started
Work with Code
128
2. Open the procedure in the Editor and click
window displays.
on the Execute toolbar. The Set Parameters and Execute
3. Complete the parameters and profiler settings.
Notes:
l
The profiler options are described by Oracle.
o
See Oracle's documentation for more information.
l
4. Click
For the hierarchical profiler, you must select a directory on the Profiler tab. If you do not,
Toad displays an error. It is recommended that you consult your DBA on the appropriate
directory to select.
again to turn off profiling.
Note: Be careful to not leave the profiler toggled on when you switch to other Toad windows. Otherwise,
Toad collects profiler data from the queries performed to populate those windows.
5. Review the profiler information. Select one of the following options:
l
Select Database | Optimize | Profiler Analysis. The Profiler Analysis window displays. View
Profiler Results
l
Click the Profiler tab beneath the Editor. Editor Profiler Tab
Notes:
l
l
If the Profiler tab is not visible, you can display it by right-clicking in the tab area and selecting
Desktop Panels | Profiler.
By default, anonymous blocks and lines not executed are not displayed. You can display them by
right-clicking the tree-view and selecting them from the menu.
View Profiler Results
The Profiler Analysis window provides data on profiler runs that is consistent with the data displayed in the
Profiler tab of the Editor. Editor Profiler Tab
The top half of the window is a graph of the showing the percent of time required to run each component of
the procedure.
Note: If you can see the pie chart labels but not the pie chart itself, resize the window horizontally to give it more
space to draw.
To access the Profiler Analysis window
Select Database | Optimize | Profiler Analysis.
Run Details
Opening a run: Selecting this displays the graph for all units within that run. Expanding a run in the tree view will
list the details of the run including Unit Type, Owner, Unit Name, and Total Time to execute.
Opening a unit: You can also select a specific unit of the selected run.
When drilling down on a unit, we see the lines of code executed and profiled. The column headers include Line
Number, Passes (how many times each line of code was executed), Total Time to execute the line, Min Time,
Max Time, and the line of Code itself. The graph changes to display the information within that unit.
Displaying in Editor:If you select a valid unit in the tree view, right-click and select display in Editor, the Editor
displays the selected unit.
Toad 12.11 Getting Started
Work with Code
129
Editor Profiler Tab
Within the Editor, the Profiler tab displays profiler runs, as root nodes, and profiler units as child nodes. The
latter are the actual code units that were executed during a profiler run. They can include anonymous blocks,
procedures, functions, and packages executed while the profiler run data was being collected. In the line
item profiler, child nodes contain the actual line data. In the hierarchical profiler, child nodes contain sub
program calls.
This tab provides an overview of the data, but does not offer the graphs that the Profiler Analysis window does.
Selecting a line item within the nodes automatically opens the referenced SQL source and displays the line
referenced by the profiler.
Note: Because each Editor tab is associated with a separate Profiler instance, navigating through your code this
way may reset the node display in the Profiler tab.
To display the Profiler Analysis window for the current data
Click Details.
Executable Line Indicators
When you open a profiler run or unit into the Editor and have the option show executable line indicators in
gutters selected, executable line indicators display as follows:
Indicator
Meaning
Blue dot with green square
Line was executed
Blue dot with red circle
Line was not executed
If Toad cannot determine when the unit was last executed, then the standard blue dot line indicators will display.
Hierarchical Profiler Filters
You can filter the results of your hierarchical profiling session. This can be useful in making sure that you only
see the results that are useful for you.
Toad will automatically filter out the system information that is added when the profiler is active. You can
manually turn these on if you want to see that information.
To create a filter
1. From the Profiler tab at the bottom of the Editor, right click the grid and select Filter.
Note: If you do not see the filter option, make sure you are actually using the hierarchical profiler.
2. Click Add to add a new filter to the filter grid. Enter the criteria you want to use to hide data. You may use
the % wildcard within the filter.
3. Enable or disable any filters desired by selecting or clearing the Enable box.
4. Repeat steps 2 and 3 if necessary.
5. Click OK.
Toad 12.11 Getting Started
Work with Code
130
Generate Explain Plans
Generate Explain Plans
Explain Plan is an Oracle function that analyzes statements for performance issues. The Explain Plan
determines the execution plan that Oracle follows when executing a specified SQL statement. The results of the
Explain Plan include the order that Oracle searches and joins tables, the types of access employed (index
search or full table scan), and the names of indexes used.
Note: Toad requires a plan table to store the Explain Plan results and creates one by default if you do not have
one. The Explain Plan table should be created in the Toad schema or an individual user schema, but not both.
To generate an Explain Plan
1. Place the cursor in a statement and click
Explain Plan tab below the Editor.
on the Execute toolbar (CTRL+E). Results display in the
Note: Toad prompts you to create the plan table if it does not exist.
2. To change the content and format of the Explain Plan:
If you want
to...
Complete the following:
Select a
different
display format
(tree, text,
graphical)
Right-click the Explain Plan and select Display Mode. Select the display format
you want to view.
Add or remove
information
Right-click the Explain Plan and select Adjust Content. For example, you can
hide or display information (such as the cardinality) or select information to
display as a column. Columns display to the left of the plan.
Note: The Explain Plan tree display lists the contents of the plan table for the
given statement ID. The query used to retrieve information for this tree is based
on the one given by Oracle in utlxplp.sql. See Oracle's documentation for more
information.
This option is only available in the tree display.
View the
plan's object
usage
Right-click the Explain Plan and select Object Usage.
View single
record
Right-click the Explain Plan and then select Single Record View. This feature
presents the information in a format that is easy to view and edit, which is very
helpful when the record contains long or complicated information.
Tip: Click . to edit the display options, such as the sorting order
and alignment.
Save Explain Plans
You can save explain plans automatically in Toad or manually save them as an external file. The first option
allows you to compare a current or historic Explain Plan to the saved file in the future.
Toad 12.11 Getting Started
Work with Code
131
To save Explain Plans automatically
1. Select View | Toad Options | Oracle | General.
2. Select Save previous Explain Plan results.
To save Explain Plans to an external file
1. Run an Explain Plan.
2. Right-click the plan and select Save to XML file or Save image.
Note: To open an XML explain plan, right-click the Explain Plan area and select Load plan from XML.
Toad 12.11 Getting Started
Work with Code
132
11
Customize the Toad Interface
Toad provides many ways for you to customize the interface to suit your work style and improve your
productivity. Most areas of the interface are customizable, from the toolbars and menus, to the grids and
workspace itself. You can also set custom defaults for actions, commands, and other tasks that Toad
performs for you.
Customize Connections
Color Code the User Interface per Connection
You can use connection colors to help you distinguish between open connections. The color coding displays
prominently on all windows related to the connection throughout Toad's user interface. For example, you may
use red for all production databases and yellow for all test databases.
The color coding displays as follows:
l
Any open window related to that connection
l
Window and Connection bar buttons
l
Status bars
To select a connection color
1. Click
in the standard toolbar to open the Database Login window.
You can also select Session | New Connection.
2. Select a color in the Color column in the connection grid, or under Color on the right-hand side.
Organize Database Connections
The Database Login window displays your previous connections in a grid format, known as the connections
grid. You can organize the connections and reduce the number of that are shown.
Toad 12.11 Getting Started
Customize the Toad Interface
133
To access the Database Login window
Click
in the standard toolbar to open the Database Login window.
You can also select Session | New Connection.
Display Only Favorite Connections
You can mark the connections that you use frequently as favorites and then hide the other connections until you
need to use them.
To select favorite connections
In the connections grid, select the Favorite check box of the connection you want to make a favorite.
To view only favorites in the connections grid
Below the connections grid, select the Show favorites only checkbox.
To view all connections in the connections grid
Below the connections grid, clear the Show favorites only checkbox.
Add Custom Columns
You can add columns to the connections grid. For example, you may want to add a Locations column if you
manage databases in multiple physical locations, or you may want to add an Environment column to
distinguish between Test and Production databases.
To add a custom column
1. Click
in the Database Login window toolbar.
2. Click Add.
3. Enter the name for your custom field.
Group Connections (Create Tree View)
You can group connections by column header to create a tree view. You can add multiple column headers to
add grouping levels.
To group connections in the data grid
1. Drag a column header into the grey area above the grid.
2. Drag additional column headers to add grouping levels.
To remove grouping
Drag the column header into the connections grid.
Hide/Display Columns
If you have a small screen area, you can hide some of the columns that display in the connections grid.
Toad 12.11 Getting Started
Customize the Toad Interface
134
To hide or show columns
1. Click
in the left-hand side of the grid headers.
2. Select the columns you want to display, or clear the checkbox for columns you want to hide.
Display Only Connections for Selected Oracle Home
If you have many connections using different Oracle homes, you may want to display only those using a
particular home in the grid.
To limit connections to one Oracle home
1. Select the Oracle home you want to display in the Connect using field on the right side of the Database
Login window.
Note: You can only connect to one Oracle home at a time. This field is disabled if you are already
connected to a database. See "Select a default Oracle Home" in the online help for more information.
2. Click the Show selected home only checkbox at the bottom of the window.
Display Tabs for Each Server or User
By default, the connections grid does not contain tabs; it is a unified grid that displays all connections. You can
change the grid to display separate tabs for each server or user. Each tab contains a grid of its database
connections.
To display tabs for each server or user
Click
at the top of the Database Login window and select Tabbed by Server or Tabbed by User.
Customize Workspaces
About Workspaces
A Workspace is a customized set of windows and connections in Toad that you can name and save. Multiple
Workspaces are supported.
You can open one workspace to work in a specific environment, such as Testing, and then quickly switch
to another one, such as Development, without having to open one set of windows and connections and
close the other.
You can create your own or use the starter Workspace named "Default Workspace." It is initially empty (that is,
contains no windows or connections). This Workspace is the only one which cannot be deleted.
Use Custom Workspaces
When you create different workspaces, you can easily resume work in the correct context as soon as you open
Toad. Create as many workspaces as you need.
Toad 12.11 Getting Started
Customize the Toad Interface
135
To create a Workspace
1. Right-click in the main Toad toolbar then select Workspaces to make certain the Workspaces
toolbar is shown.
2. In the Workspace toolbar, click
to name and save your Workspace. Your open windows and
connections are saved and will be reestablished the next time you open this Workspace.
To open a saved Workspace
Select the workspace from the Workspaces toolbar.
When you open a saved Workspace, you are notified that open connections that are not part of this workspace
will be closed. Save any changes that you want to keep before closing those windows and connections.
To save changes to your Workspace configuration
Click
in the Workspace toolbar to save changes to your Workspace configuration (newly opened windows
and connections).
Use Shortcut Keys
Customize Shortcut Keys
Toad provides dozens of default standard shortcut keys, plus you can assign new ones or customize the
standard ones. Toad also provides default menu hot keys. These are the underlined keys shown in a menu item
that you press along with the ALT key to open that menu item or command. You can change the underlined
character from its default.
Note: If you have customized your shortcut keys, you will not automatically be able to use new shortcuts added
in future Toad upgrades. However, you can reset your shortcut keys to the default in order to gain access to all
new shortcuts.
See Shortcut Keys Options in the online help for more information.
To change a menu hot key
1. Right-click the toolbar and select Customize.
2. Right-click the menu item you want to change.
3. Change the underlined character by changing the location of the ampersand in the Name field. For
example, &Tools underlines the T, while T&ools underlines the o.
To change shortcut keys
1. Click
on the standard toolbar.
Tip: You can also select View | Toad Options.
2. Select Toolbars/Menus | Shortcuts.
3. Select the command for which you want to set or change the shortcut keys.
Toad 12.11 Getting Started
Customize the Toad Interface
136
4. Type the keystrokes you want to use.
The shortcut key is changed as you type. If there is a conflict with another shortcut key, an asterisk (*)
displays in the Conflict column. You can then find the conflict and remove it.
Note: This option only allows you to use one keystroke after a control key (such as CTRL or ALT).
Print a List of Shortcut Keys
You can print a list of the shortcut keys that are provided with Toad.
See the online help for a list of popular shortcut keys.
To print the list of shortcut keys
1. Click
on the standard toolbar.
Tip: You can also select View | Toad Options.
2. Select Toolbars/Menus | Shortcuts.
3. Click the Category or Shortcut column to sort the list.
4. Click Print.
Customize Toolbars, Menus and
Commands
Enable Self-Configuring Menus
Toad menu bars can be set to configure themselves based on your work patterns. Toad collects usage data on
the commands you use most often, then personalizes the menus by moving the most used commands closer to
the top of the list and hiding commands that you use rarely.
To have menus configure themselves
1. Right click the toolbar or menu and select Customize.
2. Select the Options tab.
3. Select Menus show recently used commands first
Show/Hide Toolbars
You can show specific toolbars and hide the other ones to customize your workspace.
To change the toolbars you display
1. Right-click the toolbar area.
2. Select the toolbars you want to display, and clear the toolbars you want to hide.
Toad 12.11 Getting Started
Customize the Toad Interface
137
Rename Toolbars, Menus or Commands
Toad allows you to rename a toolbar, menu or command as desired.
1. Right click the toolbar or menu and select Customize.
2. Right-click the item that you want to change.
3. Enter the new name in the Name field. To define a hotkey, include an ampersand (&) before the letter
you want to assign as the hotkey.
Note: These are not the same as Toad shortcut keys, but rather the underlined letter for keyboard
navigation.
Create New Toolbars, Menus and Commands
If you want to heavily modify an existing toolbar or menu, it may be easier to create your own custom toolbar or
menu instead.
To create a custom toolbar or menu
1. Right-click the toolbar/menu and select Customize.
2. Create the new toolbar/menu. Review the following for additional information:
To create a...
toolbar
Complete the following:
a. Click New.
b. Enter a name your new toolbar. A blank toolbar displays in the user
interface below the existing toolbars.
menu
a. Select the Commands tab.
b. Select New Menu in the Categories field.
c. Select New Menu in the Commands field and drag it to the menu bar
where you want it located. The pointer changes to a vertical I-bar at the
menu bar.
Tip: You can create sub-menus by dragging a new menu into an
existing one.
command
a. Select the Commands tab in the Customize window.
b. Drag the command from the Commands field to the toolbar/menu. An Ibar pointer marks where the command will be dropped
Add, Reorder and Remove Commands
You can customize Toad commands to suit your requirements.
Toad 12.11 Getting Started
Customize the Toad Interface
138
1. Right click the toolbar or menu and select Customize.
2. Do any of the following:
If you want to...
Complete the following:
Change the order
of commands
Drag the item on the toolbar/menu to where you want it. An I-bar pointer
marks where the command will be dropped.
Add commands
Complete the following:
a. Select the Commands tab in the Customize window.
b. Drag the command from the Commands field to the toolbar/menu. An
I-bar pointer marks where the command will be dropped.
Remove a
command or
menu
Right-click the item and select Delete.
Show Additional Menus
You can display additional menus, such as Team Coding or Create Objects, that are hidden by default.
To display additional menus
1. Right-click the menu bar and select Customize.
2. Select the Commands tab.
3. Select Menus in the Categories field.
4. Click the menu you want to add (for example, Team Coding) in the right pane and drag it to the menu bar
where you want it located. The pointer changes to a vertical I-bar at the menu bar.
Delete a Menu
You can delete a menu from the current workspce. This does not delete the menu permanently. You can restore
it by using the Restore Defaults function.
To delete a menu
1. Right-click in the menu bar and select Customize to display the customize window.
2. Right-click the menu you want to remove. Select Delete from the menu. The menu is removed.
Reset Default Toolbars and Menus
You can restore customized or deleted toolbars and menus to their defaults.
To reset default toolbars and menus
Right-click a toolbar and select Restore defaults.
Toad 12.11 Getting Started
Customize the Toad Interface
139
It is possible to remove all the toolbars from the Editor. If this happens, you can restore the toolbars to your
windows without resetting all the default settings.
To restore lost toolbars from the Editor
1. Right-click the Desktop panels tab area.
2. Select Customize.
3. Select the Toolbars tab.
4. Select the Editor toolbars you want to display.
Lock Toolbars
You can lock the Toad toolbars so that they cannot be moved or changed.
To lock toolbars
Right-click any toolbar and select Lock Toolbars.
All toolbars are locked with this command.
To unlock toolbars
Right-click any toolbar and select Unlock Toolbars.
Effect of Upgrades on Customizations
When you customize Toad menus and toolbars, understand how they are affected the next time you
upgrade Toad:
o
Toolbar and menu customizations are not auto-imported when you upgrade Toad. This allows you to
see new Toad windows in your menus.
o
If you wish to restore your previous Toad settings, including your menu and toolbar customizations, go to
Utilities | Copy User Settings.
o
New commands in a Toad upgrade are not added to custom toolbars. However, you can see both new
commands and commands that have been completely removed from the toolbars and menus.
o
Commands that were removed from the toolbar but not the menu bar (or the other way around) do not
display in the Unused area. Because of this, it may not be obvious that you have removed a command
from one location and not the other.
To view new/removed commands
1. Right-click the toolbar/menu and select Customize.
2. Select the Commands tab.
3. To view new commands, select [New] in the Categories field.
4. To view commands you removed, select [Unused] in the Categories field.
5. To add a new/removed command to a menu/toolbar, drag the command to the toolbar/menu.
Toad 12.11 Getting Started
Customize the Toad Interface
140
Customize the Editor
Customize the Editor Layout
You can easily configure which panels display on your Editor desktop and where they display. You can select
panels to display one at a time or in groups. When you have configured it, you can save the desktop with its own
name, returning to it whenever the need arises. In addition, you can turn on Auto-save current desktop, and
however you have the desktop set when you change tabs or close Toad will be how your desktop is defined the
next time you open the Editor. You can also split the Editor to easily compare code revisions.
To display panels one at a time
1. Right-click the Editor and select Desktop.
2. Select the panel you want to display or hide.
To configure your desktop
1. Right-click the panel area near the bottom of the window.
2. Select Desktop | Configure Desktop Layout.
3. Select the panels you want to display in the Show column, and click the drop down menus in the Dock
Site column to change where the panel is docked. By default, all except the Navigator will be docked
below the Editor.
To save your desktop
1. Click
on the Desktops toolbar.
2. Enter the name you want to use for this desktop.
To use a saved desktop
From the drop-down desktop menu, select the desktop you want to use.
To restore a desktop
Click the drop-down arrow on
and select Revert to Last Saved Desktop or Restore Default Desktop.
To split the Editor
1. Right-click the Editor and select Split Editor Layout.
2. Select Left-Right or Top-Bottom.
To remove the split layout
Right-click in the Editor and select Split Editor Layout | Not Split.
Toad 12.11 Getting Started
Customize the Toad Interface
141
Use Bookmarks
Use bookmarks to help you manage files. They mark a position within the Editor so that you can easily jump
back to that line. You can set up to ten separate bookmarks within one Editor.
Note: All keystrokes assume you have not altered the default Editor keys.
To set a bookmark
Right-click and select Toggle Bookmark | Bookmark# (CTRL+SHIFT+# where # is a number between 0 and 9).
The bookmark number displays in the Editor gutter.
To clear all bookmarks
Right-click and select Clear All Bookmarks.
To clear one bookmark
Right-click and select Toggle Bookmark | Bookmark# (CTRL+SHIFT+# where # is a previously defined
bookmark between 0 and 9).
To jump back to a bookmark
Right-click and select Go to Bookmark (CTRL+# where # is a previously defined bookmark between 0 and 9).
Note: The # must be called from the number row on the keyboard. Using the Number pad will not
call the bookmark.
Auto Replace Substitutions
A substitution is a text phrase that corresponds to replacement text. For example:
l
l
If you specify a substitution pair of ACT = ACTIVITY_CENTERS, when you type ACT and press space (or
other word delimiters), ACT is automatically replaced by ACTIVITY_CENTERS
If you specify a substitution pair of NDF = NO_DATA_FOUND and you type NDF and press a delimiter,
NDF is automatically replaced by NO_DATA_FOUND
Auto Replace Substitutions are different from aliases in that you can use any group of characters to define and
complete the replacement. Aliases do not change the text in the SQL. They are a method of referring to a table
by a different name. Substitutions will actually change the text within your code to match the target keystrokes.
To edit Auto Replace entries
1. From the View menu, select View | Toad Options | Editor | Auto Replace.
2. Make changes in the Auto Replace grid.
When auto-replace is active, Toad uses several characters as auto replace activation keys. Toad will
automatically replace an activation key with the substitution value when it reaches a terminator, for example the
space key. For example, if you type teh, Toad replaces it with the word the in the Editor. Or, you can enter the
word pack and Toad will expand it to package.
An activation key will cause a matched replacement string immediately before the cursor to be replaced by
the substitution value. For example, if you have dept = DEPARTMENT in your auto replace file, you can
enter the following:
Toad 12.11 Getting Started
Customize the Toad Interface
142
l
dept[space] and the Editor will expand to DEPARTMENT .
l
dept: and the Editor will expand to DEPARTMENT:.
l
dept; and the Editor will expand to DEPARTMENT;.
Note: The activation key is always included in the expanded substitution.
You can edit this list of keys in the box if you have other needs.
Also from the Editing options window, you can import and export auto substitution files.
Toad comes with a handful of substitution pairs. You can edit and add to the list from the Auto Replace dialog.
You can then export the settings to a text file. Alternately, you can create or edit a substitutions file manually and
then import it.
Export: Saves the auto replace settings to a separate text file. If you make many changes to your auto replace
settings, it is recommended that you export them regularly for back up.
Note: If you do not export your settings to a file before you import a file, they will be lost.
Import: You can import a text file into Toad. This file can be created independently or by exporting the settings
you have created in Toad.
Importing a file overwrites the current settings.
Because it can be tedious to add large amounts of information to the substitution file directly from the interface,
you may want to edit or create a text file directly.
Use the format of string=replacement string. For example:
aax=AAX_ACCESSGROUP_APPLICATION
aca=ACA_ACTIVITY_ACTION
acc=ACC_ACTIVITY_CATEGORY
acd=ACD_ACTION_DESCRIPTION
acp=ACP_ACTIVITY_CONTACT_PARTIC
Customize the Schema Browser
Select the Left-Hand Side Display Style
You can customize how the Schema Browser displays to better suit the way you work. The most common
customization is to change how object types display in the left-hand side. Once you select a basic display style,
you can rename, hide, or rearrange the object types on the left-hand side and detail tabs on the right-hand side.
Customize Schema Browser Tabs
Tips:
l
l
l
To hide the right-hand side of the Schema Browser, press F12. You can press F12 again to
display it again.
To hide or display images and tips in the left-hand side, click
select the appropriate option.
in the Schema Browser toolbar and
In drop-down mode, you can hide leading characters of object names in the left-hand side. Right click a
column and select Hide leading characters of name. The display resets when you change the schema
or connection.
Toad 12.11 Getting Started
Customize the Toad Interface
143
To select the left-hand side display style
1. Click
in the Schema Browser toolbar.
2. Select one of the following options:
Drop-down
Displays object types in an alphabetical drop-down field.
Tabbed (single
row of tabs)
Displays object types as a single line of tabs. You must scroll through the tabs
to view all object types.
Tabbed (multi
line tabbed)
Displays multiple rows of tabs instead of the scroll bar.
Tree view
Displays object types in a tree view.
Note: You may need to close any open instances of the Schema Browser for the new browser style
to display.
Customize Schema Browser Tabs
The Schema Browser displays object types on the left-hand side and detail tabs on the right-hand side. You can
rename, rearrange, and hide the object types that display in the left-hand side or the tabs on the right-hand side.
To customize tabs and object types
1. Click
on the Schema Browser toolbar.
2. Select Configure LHS Object Types to customize the left-hand side, or select Configure RHS Tabs to
customize the right-hand side.
3. Customize the display settings.
If you want to...
Complete the following:
Rename an object type or
tab
Enter a new name in the Caption field.
Hide an object type or tab
Clear the Visible field.
Rearrange tabs
Select a tab and click the up or down arrow on the right.
Note: You can only rearrange the order of object type tabs if you are
in a tabbed view. Select the Left-Hand Side Display Style
4. To save the left-hand side settings as a configuration file, click
at the bottom of the window.
Notes: You can save and load different configurations. This gives you more flexibility when you are
working, because you can easily change the display to suit different tasks.
Toad 12.11 Getting Started
Customize the Toad Interface
144
Group Favorite Objects
You can group objects that you use frequently into a tab on the Schema Browser. These different objects can be
grouped into one or several folders. Folders are specific to an instance (not a connection or a schema).
Note: The configuration file for this tab is saved as Projects.lst in the User Files folder.
To group favorite objects
1. Click
on the Standard toolbar to open the Schema Browser.
2. Select Favorites in the object list in the left-hand side.
3. Add one or more folders to group the objects:
a. Click
on the Favorites toolbar.
b. Enter a folder name.
4. Add objects to a folder.
To search for and
select objects
Complete the following:
a. Click
on the Favorites toolbar.
b. Search for objects. Object Search
c. Highlight the objects you want to add in the Results tab and click
.
d. Select the folder where you want the object.
To add objects
directly
Complete the following:
a. Right-click an object in the left-hand side and select Add to SB
Favorites List.
b. Select the folder where you want the object.
To add scripts/files
Complete the following:
a. Right-click the folder where you want the item in the Favorites list
and select Add Files.
b. Select the file and click Open.
Note: Multi-select files to add more than one at a time.
c. Select the folder where you want the object.
Tips:
l
l
To remove objects from a folder, select the object in the Favorites list and click
.
To empty or remove favorites folders, right-click the folder and select Remove Folder to
remove the folder and its contents or Empty Folder to leave the folder in the list but remove
its contents.
Toad 12.11 Getting Started
Customize the Toad Interface
145
Customize Schema Drop-Downs
You can customize schema drop-downs by creating a list of favorites, hiding schemas, setting the default
schema for connections, and other options. Changes apply to all windows with the schema drop-down, such as
the Editor and Schema Browser.
To set a default schema
Right-click the schema in the schema drop-down and select Set <schema name> to Default Schema.
To customize schema drop-downs
1. Right-click the schema drop-down and select Customize.
2. Select schemas to categorize and click the > button.
3. To hide schemas, select Hidden Schemas in the Category field for the schema.
4. To create a new category, enter the category name in the Category field for the schema. The new name
becomes available in the Category drop-down.
5. To change when the schema is categorized, select the When to Categorize field for the schema
and click
.
Toad 12.11 Getting Started
Customize the Toad Interface
146
12
Use other Quest Products with Toad
You can access the features of the following Quest products from within Toad to expand your ability to manage
your code and your database.
l
Integrate Toad with Code Tester for Oracle®
l
Launch Quest SQL Optimizer for Oracle
l
Test in Benchmark Factory™ for Databases
l
Link to Toad Intelligence Central from Toad
Link to Toad Intelligence Central from
Toad
Toad integrates with Toad Intelligence Central to support team productivity, conformity to rules, agile
deployment processes, and management reporting and control. To use this feature, a Toad Intelligence Central
server must be installed and configured.
The Toad Intelligence Central window docks on the left-hand side of the Toad interface, or you can drag it to
make it float in the foreground.
To access the Toad Intelligence Central window
Go to View | Intelligence Central, or select
in the Toad toolbar.
Note: If the
icon is not visible, right-click the main Toad toolbar area and then select Toad
Intelligence Central.
Toad 12.11 Getting Started
Use other Quest Products with Toad
147
To connect to a Toad Intelligence Central server
l
l
In the Toad Intelligence Central window, click
.
Enter the connection information for the Toad Intelligence Central server, a display name (for use in your
own Toad environment) for the connection, and your login credentials. You can use your Windows
credentials or Toad Intelligence Central credentials if you have them. This information is stored as a
connection for faster access the next time you need to log in to that server. The connection is reestablished the next time that you open Toad.
To view notifications
Click
on the main Toad toolbar to view and manage notifications that alert you to changes made to artifacts
that are shared with you.
To publish artifacts to the TIC Server
Click
(Publish to Intelligence Central) in Toad features that support Toad Intelligence Central.
See Publish Artifacts to the Toad Intelligence Central Server in the online help for more information.
To pull artifacts from the TIC Server
In most cases, you can use the
toolbars in Toad.
(Pull from Intelligence Central) button to download artifacts from certain
See Pull Artifacts from the Toad Intelligence Central Server in the online help for more information.
Integrate Toad with Code Tester for
Oracle
®
Code Tester for Oracle® automates the process of testing PL /SQL programs, making it possible for you to
identify bugs and verify program correctness in a fraction of the time it has taken previously. Rather than write
(and maintain) thousands of lines of test code, PL /SQL programmers describe the expected behavior of their
programs through a graphical interface. Code Tester then generates the required test code, and runs it
whenever you request (either through the interface or via command line execution).
Toad is integrated with Code Tester and also contains a subset of its functionality. If you have a license for Code
Tester for Oracle and a repository of at least version 7.0, you can:
l
l
l
Run tests. You can create tests in Code Tester or in Toad (in the Editor). Either way, your tests are
stored in the Code Tester repository and can be executed in:
l
Code Tester for Oracle
l
The Editor in Toad
l
The Code Tester action in the Automation Designer
View test results. You can view test results in Code Tester or in Toad, after the test is run in the
Editor. Results can be exported to text or XML when run through the Code Tester action in the
Automation Designer.
Send test results to Toad Intelligence Central. You can upload your test results from Toad to Toad
Intelligence Central after you run the test through the Code Tester action in the Automation Designer.
Toad 12.11 Getting Started
Use other Quest Products with Toad
148
Note: Toad contains a subset of Code Tester functionality. Code Tester for Oracle itself is a standalone product.
For full information about using Code Tester, please open Code Tester and see its relevant documentation.
Launch Quest SQL Optimizer for
Oracle
This feature is available in the Xpert Edition and higher.
Quest SQL Optimizer for Oracle® automates the SQL optimization process and maximizes the performance of
your SQL statements. SQL Optimizer for Oracle analyzes, rewrites, and evaluates SQL statements located within
database objects, files, or collections of SQL statements from Oracle's System Global Area (SGA). Once SQL
Optimizer identifies problematic SQL statements, it optimizes the SQL and provides replacement code that
includes the optimized statement. SQL Optimizer also provides a complete index optimization and plan change
analysis solution. It provides index recommendations for multiple SQL statements or a SQL workload, simulates
index impact analysis, and generates SQL execution plan alternatives.
To launch SQL Optimizer for Oracle
Click
on the File toolbar.
Note: This icon is also available in additional locations, such as the Auto Optimize SQL and the
Create and Alter windows for some object types.
Test in Benchmark Factory™ for
Databases
Benchmark Factory™ for Databases - Oracle Edition is a database performance and code scalability testing tool
that simulates users and transactions on the database and replays production workload in non-production
environments. This enables developers, DBAs, and QA teams to validate that their databases will scale as user
load increases, application changes are made, and platform changes are implemented.
You can connect to Benchmark Factory from Toad, set Performance Test Settings and send the test to
Benchmark Factory for further analysis.
To open Benchmark Factory
Select one of the following:
l
l
Schema Browser pages - Right-click on the object to be tested and select Test
Performance.
Code Road Map - Right-click on the object to be tested and select Test Performance.
Note: When you choose to send an object to Benchmark Factory, you need to set Benchmark
Factory properties in addition to the parameters required by the database object. See the
Benchmark Factory documentation for more information.
Toad 12.11 Getting Started
Use other Quest Products with Toad
149
Use Spotlight Essentials
Spotlight Essentials, (formerly Project Lucy) is a process that analyzes data from your database to let you know
how it is running. Learn more at SpotlightEssentials .com.
To install and configure Spotlight Essentials
1. Install and configure Spotlight for Oracle. For help, see the documentation and online help for
that product.
2. Register for Spotlight Essentials at the Web site: SpotlightEssentials.com.
3. Log in to SpotlightEssentials.com, then go to Settings to make note of your token.
4. Run Spotlight for Oracle.
5. Select View | Options | Diagnostic Server Configuration, then click Install to install and configure
Spotlight for Oracle Diagnostic Server (DS) and the required Web Publisher. Install on any server. For
continuous monitoring, install on a server that is always running. You will need to know the domain of
the installation machine and login credentials. These components are installed as Windows services set
to start automatically.
To set up Spotlight Essentials in Toad
1. In Toad, go to View | Toad Options | Online.
2. Under Spotlight Essentials Login, enter your Email and Password and click Login.
3. Click Database | Diagnose | Spotlight Essentials or select
window is open.
4. Click
if the Database Browser
in the Spotlight Essentials toolbar.
5. Under Server running Diagnostic Server, enter the name of the server and port number where
Diagnostic Server is installed. The default port number is 8830.
6. Double click a database name under Available Databases to move it to the Databases being
monitored pane. A connection dialog is displayed:
a. Confirm the connection information (from the tnsnames.ora file) or complete any blank or
incorrect fields.
b. Supply login credentials.
c. Deselect Enabled if you do not want this database to be monitored at this time.
Note: To edit an entry, double-click it. To delete an entry, use the backward arrow to move it to
Available Databases.
7. Move other databases to the Databases being monitored pane as needed.
8. Close the dialog to start the monitoring. It may take about a day for the Diagnostic Server to collect
enough information to display. Until then, the Spotlight Essentials window remains blank.
Toad 12.11 Getting Started
Use other Quest Products with Toad
150
To work with the Spotlight data
1. Under Name in the top pane, select the name of the database. By default, Toad selects the current
database connection when Spotlight is launched (if the database was configured in the Diagnostic
Server setup).
2. View Oracle performance data in the lower left pane, and view the system events in the lower right pane.
Toad shows the following graphical statuses that correspond to the health scores returned by Spotlight
Essentials:
Health Score
Health Score Symbol
Unknown
< 33
34 - 65
>66
Toad 12.11 Getting Started
Use other Quest Products with Toad
151
About us
Ab o u t u s
We are more than just a name
We are on a quest to make your information technology work harder for you. That is why we build
communitydriven software solutions that help you spend less time on IT administration and more time on
business innovation. We help you modernize your data center, get you to the cloud quicker and provide the
expertise, security and accessibility you need to grow your data-driven business. Combined with Quest’s
invitation to the global community to be a part of its innovation, and our firm commitment to ensuring customer
satisfaction, we continue to deliver solutions that have a real impact on our customers today and leave a legacy
we are proud of. We are challenging the status quo by transforming into a new software company. And as your
partner, we work tirelessly to make sure your information technology is designed for you and by you. This is our
mission, and we are in this together. Welcome to a new Quest. You are invited to Join the Innovation™.
Our brand, our vision. Together.
Our logo reflects our story: innovation, community and support. An important part of this story begins with the
letter Q. It is a perfect circle, representing our commitment to technological precision and strength. The space in
the Q itself symbolizes our need to add the missing piece — you — to the community, to the new Quest.
Contacting Quest
For sales or other inquiries, visit https://www.quest.com/company/contact-us.aspx or call +1-949-754-8000.
Technical support resources
Technical support is available to Quest customers with a valid maintenance contract and customers who have
trial versions. You can access the Quest Support Portal at https://support.quest.com.
The Support Portal provides self-help tools you can use to solve problems quickly and independently, 24 hours
a day, 365 days a year. The Support Portal enables you to:
l
Submit and manage a Service Request
l
View Knowledge Base articles
l
Sign up for product notifications
l
Download software and technical documentation
l
View how-to-videos
l
Engage in community discussions
l
Chat with support engineers online
l
View services to assist you with your product
Toad 12.11 Getting Started
About us
152
">
/
Scarica
Solo un promemoria. Puoi visualizzare il documento qui. Ma soprattutto, la nostra IA l''ha già letto. Può spiegare cose complesse in termini semplici, rispondere alle tue domande in qualsiasi lingua e aiutarti a navigare rapidamente anche nei documenti più lunghi o complicati.
Pubblicità