Vous êtes sur la page 1sur 26

Discovering the Hidden Treasures of Toad for Oracle

Written by

Bert Scalzo Quest Software, Inc.

TECHNICAL BRIEF

2010 Quest Software, Inc. ALL RIGHTS RESERVED. This document contains proprietary information protected by copyright. No part of this document may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying and recording for any purpose without the written permission of Quest Software, Inc. (Quest). The information in this document is provided in connection with Quest 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 products. EXCEPT AS SET FORTH IN QUEST'S TERMS AND CONDITIONS AS SPECIFIED IN THE LICENSE AGREEMENT FOR THIS PRODUCT, QUEST 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 NONINFRINGEMENT. IN NO EVENT SHALL QUEST 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 HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Quest 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 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 World Headquarters LEGAL Dept 5 Polaris Way Aliso Viejo, CA 92656 www.quest.com E-mail: legal@quest.com Refer to our Web site for regional and international office information.

Trademarks
Quest, Quest Software, the Quest Software logo, AccessManager, ActiveRoles, Aelita, Akonix, AppAssure, Benchmark Factory, Big Brother, BridgeAccess, BridgeAutoEscalate, BridgeSearch, BridgeTrak, BusinessInsight, ChangeAuditor, ChangeManager, Defender, DeployDirector, Desktop Authority, DirectoryAnalyzer, DirectoryTroubleshooter, DS Analyzer, DS Expert, Foglight, GPOADmin, Help Desk Authority, Imceda, IntelliProfile, InTrust, Invirtus, iToken, I/Watch, JClass, Jint, JProbe, LeccoTech, LiteSpeed, LiveReorg, LogADmin, MessageStats, Monosphere, MultSess, NBSpool, NetBase, NetControl, Npulse, NetPro, PassGo, PerformaSure, Point,Click,Done!, PowerGUI, Quest Central, Quest vToolkit, Quest vWorkSpace, ReportADmin, RestoreADmin, ScriptLogic, Security Lifecycle Map, SelfServiceADmin, SharePlex, Sitraka, SmartAlarm, Spotlight, SQL Navigator, SQL Watch, SQLab, Stat, StealthCollect, Storage Horizon, Tag and Follow, Toad, T.O.A.D., Toad World, vAutomator, vControl, vConverter, vFoglight, vOptimizer, vRanger, Vintela, Virtual DBA, VizionCore, Vizioncore vAutomation Suite, Vizioncore vBackup, Vizioncore vEssentials, Vizioncore vMigrator, Vizioncore vReplicator, WebDefender, Webthority, Xaffire, and XRT are trademarks and registered trademarks of Quest Software, Inc in the United States of America and other countries. Other trademarks and registered trademarks used in this guide are property of their respective owners.

Technical Brief: Discovering the Hidden Treasures of Toad for Oracle

Contents
Introduction.................................................................................................................................................... 3 Toad Editions ............................................................................................................................................. 4 Base (Standard) Edition ......................................................................................................................... 4 Editions for Developers .......................................................................................................................... 4 Editions for DBAs ................................................................................................................................... 5 Toad Treasures ............................................................................................................................................. 7 Project Manager ......................................................................................................................................... 7 Creating a Custom View with Project Manager ..................................................................................... 7 Project Manager Works Like the Schema Browser ............................................................................. 10 Project Manager Can Create Real Files .............................................................................................. 11 Customizing Project Manager .............................................................................................................. 12 Application Designer ................................................................................................................................ 13 Repeating or Scheduling a Task .......................................................................................................... 14 Running an Application ........................................................................................................................ 17 Data Import and Export ............................................................................................................................ 18 Using Export File Browser to Peek Inside a Dump File ....................................................................... 18 Viewing the Data in a Standard Toad Data Grid ................................................................................. 19 Code Xpert ............................................................................................................................................... 19 Helping Developers Find Problematic Code ........................................................................................ 19 Helping DBAs Track Down Performance Problems ............................................................................ 21 SQL Optimizer for Oracle......................................................................................................................... 21 Tuning a Problematic Query Automatically.......................................................................................... 21 Conclusion................................................................................................................................................... 23 About the Author ......................................................................................................................................... 24

Technical Brief: Discovering the Hidden Treasures of Toad for Oracle

Introduction
Quest Software has been selling Toad for nearly a decade now. Some interesting facts highlight Toads growth from its humble freeware beginnings:
Toad has over one million users worldwide Toad is considered the de facto standard Quest will soon be releasing version 10.0 of Toad

Surprisingly, people are always genuinely amazed by the depth and breadth of the product: even longtime users routinely find new things they never knew Toad could do. Its in that spiritunearthing Toad gemsthat this paper is written. The idea will be to present some useful tidbits for everyone, regardless of job function or Toad experience.

Technical Brief: Discovering the Hidden Treasures of Toad for Oracle

Toad Editions
Lets start by looking at how Toad is bundled and sold. Some bundles offer much more functionality than the base product, and youll want to find the right set of features for your needs.

Base (Standard) Edition


First is the base Toad for Oracle edition, which started the whole phenomenon. It offers far too many features to list, but theres a brief description in the figure in the next section. People genuinely love this product, often reporting they cannot do their jobs without it. The other Toad bundles are generally described in terms of what they provide above and beyond the base edition.

Editions for Developers


For developers, Toad offers a plethora of practical and productive features in three editions:
Toad for Oracle Professional Toad for Oracle Xpert The all-inclusive Toad Development Suite

These editions include key features not found in the base edition that professional database application developers and PL/SQL developers often need. If youre developing enterprise database applications, two great choices to help you write efficient code are Toad for Oracle Professional (which includes Code Xpert) and Toad for Oracle Xpert (which provides SQL optimization and what-if index analysis). If you need to test the functionality and scalability of your database applications as well, then the Toad Development Suite for Oracle best fits the bill, with Benchmark Factory for Databases and its PL/SQL code testing tool, Quest Code Tester for Oracle, from Steven Feuerstein Mr. PL/SQL himself.

Technical Brief: Discovering the Hidden Treasures of Toad for Oracle

The diagram below details the features of all three developer editions in comparison to the base edition:

Figure 1. Toad for Oracle base and developer editions

Editions for DBAs


But Toad is not just for developers: a growing percentage of customers use Toad either as their primary database administration tool or as a handy complement to Oracle Enterprise Manager (OEM). Accordingly, Quest offers two DBA-oriented bundles. First, for DBAs who need just a little more than what the base edition includes, Quest offers the DB Admin Module (formerly DBA Module), which must be purchased with or added on to another edition of Toad for Oracle. In a nutshell, the DB Admin Module adds key functionality for performing database administrative tasks. For example, this module adds tabs to the Toad Schema Browser for all the extended Oracle database object types (including contexts, dimensions, directories, libraries, policies, policy groups, profiles, refresh groups, resource plans, resource plan groups, roles, and tablespaces.).

Technical Brief: Discovering the Hidden Treasures of Toad for Oracle

The Toad DBA Suite for Oracle provides many advanced database administration features, including ASM manager, auditing, compare database, compare and sync schemas, database Health Check, database monitor, index monitor, and GUI interfaces to DBMS_FLASHBACK and DBMS_REDEFINITION. The Toad DBA Suite for Oracle also includes three other critical facilities for your tool belt:
Toad Data Modeler for professional database design Benchmark Factory for database load generation and stress testing A single database instance copy of Quests award winning Spotlight for Oracle database diagnostics to identify the root causes of performance issues

Figure 2. Toad for Oracle DBA editions

Technical Brief: Discovering the Hidden Treasures of Toad for Oracle

Toad Treasures
Now that you know which Toad edition suits your needs, lets look at some useful but oft en overlooked features. Lets dig up some Toad treasure! Below are five features truly worth your investigation. I will show you how each feature can enhance your productivity and hope that it will entice you to either dig further on your own or view the webcast, because its much more easier to relate to it when you see Toad in action.

Project Manager
Some time ago, Quest added a great new productivity enhancement to Toad for Oracle called Project Manager. Everyone who sees it says, Wow, cool! Thats going to make my work easier. But Project Manager remains underutilized, so Im going to explain its benefits and hope youll try it out.

Creating a Custom View with Project Manager


Everyone uses and likes the Toad Schema Browser. Its a great visual portal i nto the database object structures. But most application developers tend to work on tasks or projects, not the scope of the entire database at once. So the Schema Browser can present information overload. Sure, we can easily customize the Schema Browser to turn off tabs we dont need, set filters on tabs, and have several other customization techniques, but these options are global in scope. What we want is a Schema Browser in which content is based on the task or project at hand. Thats where Project Manager is invaluable. Lets create a quick demo project and see what I mean. Below I have the Schema Browser open to the tables for my MOVIES schema, but I want to work with only the four tables highlighted on the left for this task. When I select to send them to Project Manager, I am prompted for a project name; lets call this Berts Demo.

Technical Brief: Discovering the Hidden Treasures of Toad for Oracle

Figure 3. Sending a subset of tables to Project Manager

Since I know Im going to be doing some PL/SQL coding on procedures, functions, and packages, Ill repeat this step for all the objects that I think Im going to need to work with for this task. Each time, Ill select the same project so that Ill build an interesting set to work with.

Technical Brief: Discovering the Hidden Treasures of Toad for Oracle

Now when I open Toad Project Manager, I see the following:

Figure 4. A Toad project with just the objects needed for a task

This example might seem rather trivial so far, but I now have a Toad project that contains only those objects I need to work with for this task. Unlike the Schema Browser, which can show either all the objects or some based upon basic filters, the Toad Project Manager lets me build my own custom view of the database object world.

Technical Brief: Discovering the Hidden Treasures of Toad for Oracle

Project Manager Works Like the Schema Browser


But thats just one of the great things about Project Manager. Project Manager works in exactly the same way as the Schema Browser. In particular, the right-click context menu is identical, and you get the same display on the right if you select an item. Look at the screenshot below: Berts Demo has just what I need and it works exactly like the Schema Browser.

Figure 5. Toad Project Manager

Technical Brief: Discovering the Hidden Treasures of Toad for Oracle

10

Project Manager Can Create Real Files


Lets add a directory to this project. I dont mean an Oracle database object of a directory, but rather just a directory on my local Windows computer. The figure below shows how to add a directory:

Figure 6. Adding a directory to a project

Technical Brief: Discovering the Hidden Treasures of Toad for Oracle

11

What did that accomplish? To find out, lets drag and drop the CUSTOMER table to that directory. Ill be prompted for the name of a file to be created:

Figure 7. Specifying a file name

So what just happened? Obviously the file is going to show up in Project Manager as a file under the directory. But if I go out to the Windows Explorer and look, Ill find an actual file with the DDL to create that table and all of its supporting structures.

Customizing Project Manager


If you dont like that specific behavior, thats okayall of Project Managers behavior is 100% user customizable. As the screenshot below shows, you can change Project Managers behavior for file associations, drag-and-drop operations, and double-click operations. In other words, you can customize how the Project Manager interface operates for various object types so that Toad works the way you want. That means youll get things done quicker. And increased productivity is what Toad is all about. A quick demo of Project Manager can be found on Toad World.

Technical Brief: Discovering the Hidden Treasures of Toad for Oracle

12

Figure 8. Customizing Project Manager

Application Designer
Toad has always had the ability to automate certain screens to run from the command line, but it required a little learning curve that frankly people seemed to feel was just too much. Many of them asked us to make a tool set for Toad that would allow them to create their own logical organization or workflow for basic, low-level tasks. Application Designer, available beginning in Toad for Oracle 9.7, does just that; it is robust and capable, but requires only a simple GUI interaction, with nothing else to learn. So lets dig deeper using a couple of examples.

Technical Brief: Discovering the Hidden Treasures of Toad for Oracle

13

Repeating or Scheduling a Task


A database developer or database business analyst might need to do something in Toad related to the data content, and then repeat or schedule that task. Lets consider a basic example. My manager tells me that I need to build what he calls a report of our customers in Texas once a month. We need to e-mail or ftp that file to someone else who must update his database to match ours. Since I know he is going to upload my report into his database, I decide that to generate basic ANSI SQL commands to INSERT that data, though I could easily have chosen any of the many other formats that Toad supports, such as Excel spreadsheet, comma delimited, Access database, or XML. I open Toad Editor, enter my query, and press Execute to make sure it works as intended. Then I rightclick anywhere on the data grid and choose Save As from the context menu. On the Save as screen, I choose my options and parameters and click OK to verify that it works correctly. Then I reopen the Save As dialog; this time I click the camera icon at the bottom. That opens a dialog for creating (but not running) a user-defined Action to perform this task, as shown below:

Figure 9. Creating a user-defined action in the Toad editor

Technical Brief: Discovering the Hidden Treasures of Toad for Oracle

14

Before we can continue, we need to define the following terms that are used in Toad:
ActionAn atomic chunk of Toad functionality that has been encapsulated for the purpose of executing, scheduling, sharing and building Toad applications AppOne or more Actions designed to work in unison as a mini Toad application App DesignerThe window used to create and manage applications

In this example, Ive simply defined the Save As for my editor query of Texas-only customers into an action called Save as Texas Customers and placed that into an application called Texas Customers. Now lets open App Designer to see the result.

Figure 10. Results of the App Designer action

I can now choose to run or schedule that application. If I choose to run it, Toad is simply executing the application within my currently running instance of Toad. That is, behind the scenes, it will execute the query and perform a Save As, but I wont see anything flash by; Ill just see a run status indicator such as the green Completed bar shown above. If I go into my C:\Temp directory, Ill find that file as expected.

Technical Brief: Discovering the Hidden Treasures of Toad for Oracle

15

If I schedule the application instead of running it, a wizard is invoked, as shown below.

Figure 11. Schedule Action Item wizard

I have now created a Windows task on my PC that will execute Toad in command-line mode in my C:\Temp directory, passing the necessary parameters so that it will run the application and all its actions as if it had been multi-action. Thats it: nothing to learn like before with the old command -line method.

Technical Brief: Discovering the Hidden Treasures of Toad for Oracle

16

So where can you do this? Basically on any screen that has the camera icon at the bottom, and the number of those screens is growing as we speak. What if I dont want to go into the actual screen, but instead I want to build the application and its actions right there in the App Designer screen? That is also an option. The tabs along the right side offer toolbar icons for the tasks weve already defined as actions. That list is also growing.

Running an Application
Now lets look at an example for a DBA, which will also introduce you to many other possibilities for using Toad Application Designer. The application shown belo w checks my database to see if its up. If it is, it runs a Health Check, which will e-mail me the results. If not, Ill start the database first, and then run the Health Check. The possibilities are nearly limitless.

Figure 12. Running an application

Technical Brief: Discovering the Hidden Treasures of Toad for Oracle

17

Data Import and Export


One of the most common development and test database tasks is to refresh data for users to run their code against. For this, many developers use the Oracle import and export utilities. But you really cannot see into a dump file, other than to ask for a table of contents. Frankly, thats just not good enough. What I want is a tool something like WinZipa utility that enables me to peek inside the dump file and select what I want.

Using Export File Browser to Peek Inside a Dump File


Toad solves this problem with the Export File Browser, which is available by selecting Database | Export | Export File Browser. Theres really nothing else like the Export File Browser out there. Not only can I view the contents of the dump file via the navigator tree view on the left side (shown below), but I can see the DDL for that object and its data under the tabs on the right side as well, so I can cut and paste the DDL to make sure the objects exist before the import.

Figure 13. Viewing the contents of a dump file and the DLL

Technical Brief: Discovering the Hidden Treasures of Toad for Oracle

18

Viewing the Data in a Standard Toad Data Grid


Another handy tip: I can also see the data in a standard Toad data grid. This means I get all my right-click menu options such as Save As, Print, and Row Count. Note that the Export File Browser must access the dump file to perform its job, so the file must reside on your PC (remember, Toad has a built-in FTP tool). Plus, your PC must parse that dump file to populate the browser contents, so a huge file may take a little while; be patient. Once it has opened and thus parsed a file, though, Toad is smart enough not to do it again, so even a 100GB dump file will open quickly on subsequent uses. A quick demo of Data Import and Export can be found on Toad World.

Code Xpert
Developers want to write better code; DBAs want to find any code that doesnt perform well. Toad helps solve both of these challenges with Code Xpert.

Helping Developers Find Problematic Code


Developers dont always have time to perform formal code reviews. And even when they do, the code review is only as good as that sessions participants. Whats needed is some way to automate or streamline the process, and make the results more consistent. In particular, it would be great to enable developers to eliminate all the easily-findable issues in their code before going to a formal code review, so as not to squander the time of key talents. In fact, if the automated review is good enough, we might be able to forgo some formal code reviews altogether, saving substantial IT staff time. For example, look at the silly code below. Wouldnt it be nice if I could get automated help reviewing it before I show it to my colleagues and have them think even less of me?

Figure 14. Sample code that needs review

Technical Brief: Discovering the Hidden Treasures of Toad for Oracle

19

How can we fix this horrible code? We can use Code Xpert, a utility inside the Toad Editor. Its like having a mentor review your work with the push of a button. By merely switching to the Code Xpert tab near the bottom of the Editor screen and clicking the Perform Code Review button, I get output like that shown here:

Figure 15. Code Xpert automatically finds problems in code

Code Xpert includes over one hundred programming rules that are defined by default, but it mercifully restricts itself to the top 20 as defined by industry experts. In this example, Code Xpert has found a GOTO and advises against using it. If you dont like the predefined rule sets, you can easily select the rules that youd like to check. You can even create your own custom rule sets. Additionally, the Reports tab shows several key items worth having access to:
A CRUD matrix of the tables referenced by the code Software Engineering Institute (SEI) standard metrics (i.e., Halstead Complexity Measure, MC Cabes Cyclomatic Complexity, and Maintainability Index) for the code A simple Toad color code of green, yellow, or red based upon the cumulative results from the standard metrics

Furthermore, Code Xpert rates all your SQL statements as simple, complex or problematic, with their explain plans if you like. That way you can focus on tuning just those statements that warrant it.

Technical Brief: Discovering the Hidden Treasures of Toad for Oracle

20

Helping DBAs Track Down Performance Problems


What if youre a DBA trying to track down a performance problem somewhere in the millions of lines of PL/SQL code in your database? Toad has a batch mode interface in Code Xpert (shown below) designed for that very purpose. It scans the code and highlights line that needs attention finding the proverbial needle in the haystack for you.

Figure 16. Code Xpert identifies code that causes performance problems

You can also use Code Xpert to create project deliverables related to overall code quality. If you work on government projects or are a consultant tasked with producing such items, batch mode Code Xpert can be a life saver. A quick demo of Code Xpert can be found on Toad World.

SQL Optimizer for Oracle


SQL may be a simple language in terms of commands, but writing SELECT statements can be both an art and a science unto itself. Ive seen five-line SELECTs that take several hours to run and 100-line SELECTs that take just seconds to run. When you start regularly using more complex SQL features such as joins, sub-selects, correlated sub-queries, group by, having, and order by, predicting and tuning the performance of a query can become a daunting challenge.

Tuning a Problematic Query Automatically


As we saw in the previous section, Code Xpert can help you find a problematic query very quickly. But once you find it, then you need to fix it so it runs faster. And fixing a complex query can be quite difficult. Again Toad comes to the rescue. Toad for Oracle Xpert Editions SQL Optimizer can help you tune a query, or even automatically tune it for you, no matter how complex the query is. SQL Optimizer, shown below, provides a complete SQL tuning and optimization workbench for quickly and intelligently achieving maximum performance. It can suggest query re-writes and even database structural changes (such as adding or subtracting indexes, partitioning database objects, or moving objects to different tablespaces).

Technical Brief: Discovering the Hidden Treasures of Toad for Oracle

21

Figure 17. Quest SQL Optimizer automatically rewrites SQL and tests all the options

Once SQL Optimizer has identified all the possible scenarios that might result in better performance, it can run them all and report back on the best-performing SQL alternatives. In fact, lazy people like me just run SQL Optimizer and push two buttons: one to generate all the likely best re-writes and one to test them. It automatically displays the winner. So with practically no effort, even I can produce SQL code thats guaranteed to be the fastest possible. And I dont even really have to describe explain plans, outlines, hints, or any other advanced Oracle concepts. SQL Optimizer simply helps you find the best code possible as quickly as possible, regardless of your tuning and optimization skill set. A quick demo of SQL Optimizer can be found on Toad World.

Technical Brief: Discovering the Hidden Treasures of Toad for Oracle

22

Conclusion
I hope you found some of the features of Toad that Ive described interesting enough to warrant further inspection on your own. I believe all of them can increase your productivity and help you achieve maximum performance for minimum investment in time and effort, regardless of your role. Be sure to also visit the Toad World web site at www.toadworld.com; you will find numerous blogs, coffee break byte videos, technical papers, and presentations to help you to get the most from Toad for Oracle.

Technical Brief: Discovering the Hidden Treasures of Toad for Oracle

23

About the Author


Bert Scalzo has worked with Oracle databases for well over two decades; his key areas of interest include data modeling, database benchmarking, database tuning and optimization, Star Schema data warehouses and Linux. Bert is the author of books including Oracle DBA Guide to Data Warehousing and Star Schema and Toad Pocket Reference. He recently co-authored Database Benchmarking for Oracle and SQL Server.

Technical Brief: Discovering the Hidden Treasures of Toad for Oracle

24

TECHNICAL BRIEF

About Quest Software, Inc.


Quest Software (Nasdaq: QSFT) simplifies and reduces the cost of managing IT for more than 100,000 customers worldwide. Our innovative solutions make solving the toughest IT management problems easier, enabling customers to save time and money across physical, virtual and cloud environments. For more information about Quest solutions for application management, database management, Windows management, virtualization management, and IT management, go to www.quest.com.

Contacting Quest Software


PHONE

800.306.9329 (United States and Canada) If you are located outside North America, you can find your local office information on our Web site. sales@quest.com Quest Software, Inc. World Headquarters 5 Polaris Way Aliso Viejo, CA 92656 USA


E-MAIL MAIL

Contacting Quest Support


Quest Support is available to customers who have a trial version of a Quest product or who have purchased a commercial version and have a valid maintenance contract. Quest Support provides around-the-clock coverage with SupportLink, our Web self-service. Visit SupportLink at https://support.quest.com. SupportLink gives users of Quest Software products the ability to: Search Quests online Knowledgebase Download the latest releases, documentation, and patches for Quest products Log support cases Manage existing support cases View the Global Support Guide for a detailed explanation of support programs, online services, contact information, and policies and procedures.

5 Polaris Way, Aliso Viejo, CA 92656 | PHONE 800.306.9329 | WEB www.quest.com | E-MAIL sales@quest.com

If you are located outside North America, you can find local office information on our Web site.
2010 Quest Software, Inc. ALL RIGHTS RESERVED. Quest, Quest Software, the Quest Software logo and Toad are registered trademarks of Quest Software, Inc. in the U.S.A. and/or other countries. All other trademarks and registered trademarks are property of their respective owners. TBD_HiddenTreasures_Toad4Oracle_US_EC_20101103