Toad Hidden Treasure

advertisement
Toad Hidden Treasure
Quest Software has been selling Toad® for nearly a decade now. In fact Toad’s tenth birthday is rapidly
approaching. Some interesting facts have evolved over that time from its humble freeware beginnings:

Toad has over 1-million users world wide

Toad is considered the de-factor standard

Toad will soon be releasing a version 10.0
But what’s often quite surprising is that people are always genuinely amazed by the depth and breadth
of the product – including long time users who routinely find new things they never knew Toad could do.
It’s in that spirit – unearthing Toad gems – that this paper is written. The idea will be to present some
useful tidbits for any reader – no matter what their job description and/or Toad experience.
Let’s start by looking first at how Toad is bundled and sold. That’s key because some bundles offer much
more functionality than the base product. So you need to know what bundle you currently own. It might
be that you have tons of features you purchased and don’t use. Likewise, it could be that you bought a
bundle just shy of what you really needed/wanted – and thus you may need to upgrade in order to get
the features you want. Either way, knowing about Toad versions will assist in your selection.
There is of course the standard or base Toad for Oracle edition – which started the whole phenomenon.
It offers far too many features to list – and people genuinely love this product (i.e. they cannot do their
jobs without it). The remaining Toad bundles are generally expressed in terms of that which they offer
above and beyond the standard or base edition.
For developers, Toad offers a plethora of critically practical and productive features via its professional
bundle, xpert bundle and the all inclusive development suite. As you examine the diagram below, you’ll
see that for professional database application developers – the non-standard Toad bundles offer many
key features that any PL/SQL developer may well need. Since we all desire to write efficient code – Toad
for Oracle Xpert with SQL Optimizer, virtual index capability (i.e. “what-if” index analysis), and the Code
Xpert (from the professional version) offers the single best platform for developing enterprise database
applications. And if you need to test your database application as well – then Toad Developer Suite best
fits the bill, with its industry leading PL/SQL Code Tester (from Steven Feuerstein – Mr. PL/SQL himself).
But Toad is not just for developers anymore. We have a growing percentage of Toad customers using it
either as their sole, primary database administration tool or as a handy compliment to Oracle Enterprise
Manager (OEM). Now looking below at the DBA oriented bundles, you’ll see that there are some very
interesting options here as well. For those DBA’s who just need a little more than what the standard or
base version offers, Quest has the DB Admin Module – which must be purchased with or added onto
another edition of Toad for Oracle. In a nutshell, the DB Admin Module adds some more functionality
for those people who need to perform database administrative tasks not found in the base product. For
example, this version adds many additional tabs to the Toad Schema Browser for all the extended Oracle
database objects types (e.g. contexts, dimensions, directories, libraries, policies, policy groups, profiles,
refresh groups, resource plans, resource plan groups, roles, tablespaces and more.). There are also a
great number of more intense database administrative features – including ASM manager, auditing,
compare database, compare & sync schemas, database health check, database monitor, index monitor,
and GUI interfaces to DBMS_FLASHBACK and DBMS_RDEFINITION. The Toad for DBA Suite offers all this
plus three other critical facilities for your tool belt: Toad Data Modeler for professional database design,
Benchmark Factory for database load generation and stress testing, plus a single database instance copy
of Quest’s award winning Spotlight for Oracle database diagnostic and monitoring solution. That’s one
heck of a lot of tools for one reasonable fee.
So assuming that you now have the proper Toad version, bundle or suite based upon your job function
or needs – let’s look at some useful but often overlooked features. Let’s dig up some Toad treasure 
Below are five features truly worth your investigation. In the corresponding webcast for this paper, I’ll
dig a little deeper here into each to clearly convince you of your need to learn and use them. But this
paper doesn’t have the luxury of space or time for demoing all the neat stuff. So instead I’m just going to
show you what I think are likely to be key productivity enhancing aspects that will entice you to either
dig further on your own or attend one of the webcasts on this material – because it’s so much more
awesome to see this stuff live and in person.
Project Manager
Some time ago, Toad added a great new productivity enhancer called the Project Manager. Yet it still
remains underutilized – and yet everyone who sees it says “wow, cool – that’s going to make my work
easier”. So I’m going to bring it up again – and hope it sticks this time.
Everyone uses and likes the Toad Schema Browser. It’s a great visual portal into 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 don’t need, we can set filters on tabs we do, and
several other customization techniques – but it’s global in scope and not tied to the task at hand. What
we want is a Schema Browser whose content is based upon the task or project being done. Now I’ll go
even one better – this new interface is also 100% user customizable in terms of how it operates. Let’s
create a quick demo project and show what I mean.
Below I have the Schema Browser open to tables for my MOVIES schema – but I only want to work with
the four highlighted tables for this task (because there are just too many to view here). So I’ll choose to
send them over to the project manager. It’s going to prompt for a project name – so we’ll call this Bert’s
Demo. Now since I know I’m going to be doing some PL/SQl coding on procedures, functions and even
packages – I’m going to repeat this step for all the objects that I think I’m going to need to work with for
this task. Each time I’ll select the same project – so that I’m building up an interesting set to work with.
If I now open up the Toad Project Manager, I’ll see the following:
It may seem rather trivial so far – but I now have a Toad project that contains only those objects which I
need to work with for this task. Unlike the Schema Browser that can either show all the objects or some
based upon basic filters – the Toad project manager let’s me build my own custom view of the database
object world. But that’s just the start of it. The Project Manager works exactly the same as the Schema
Browser (shown below), the right hand mouse context menu is identical – plus if you select an item, you
get the exact same right hand side display. So look again at the screen snapshot below – “Bert’s Demo”
has just what I need and works exactly like the Schema Browser. But there’s more – so read on.
Let’s add a directory to this project – and I don’t mean an Oracle database object of a directory, but
rather just a directory on my local Windows computer. So here’s an example of doing that.
So the logical question is “What did that accomplish?” Watch this. I’ll simply drag-and-drop the
CUSTOMER table to that directory – and I get prompted for a file name to create.
So what just happened? Obviously the file is going to show up on the Project Manager as a file under the
directory. But if I go out to the Windows Explorer and look – I’ll find an actual file with the DDL to create
that table and all of its supporting structures. Don’t like that specific behavior, that’s OK – all the Project
Manager behavior is 100% user customizable. As the screen snapshot below shows, you can change the
Project Manager’s 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
such that Toad works the way you want. That means you’ll get things done quicker – which is increased
productivity. And that’s what Toad is all about 
Application Designer
Now while the Toad Project Manager is great, it too has some limitations – namely, we designed the
screen and functionalities that you can associate. Lots of Toad users asked why not just provide basic
functionalities and a mechanism to work with them. In other words, make Toad a tool set for letting
users create their own logical organization or workflow of those basic, low level tasks. So starting in
Toad 9.7, we offer the Application Designer – which does just this. Now Toad has always had the ability
to automate certain screens to run from command line, but it required a little learning curve that frankly
people seemed to feel was just too much. So we designed the Toad Application Designer with the goal
to make this entire process trivially easy to use, yet robust and capable – i.e. plus all based off a simple
GUI interaction, with nothing else to learn. So let’s dig deeper.
First, let’s demonstrate an example that a typical database developer or database business analyst
might encounter – namely, doing something in Toad related to the data content and then repeat or
schedule that task. So please with what may seem like a silly example – I’m just trying to ignite the light
bulb in your head for what something like this could mean for you:
My manager tells me that once per month I need to dump what he calls a “report” of our customers in
Texas. We need to email or ftp that file to someone else who must update their database to match ours.
Since I know they are going to upload that into their database, I decide that generating basic ANSI SQL
commands to INSERT that data will suffice. It could have easily been any of the many data formats Toad
can save data to – such as Excel spreadsheet, comma delimited, Access database, XML and many others.
So look at the screen snapshot below. I open a Toad Editor and enter my query – and press “Execute” to
make sure it works as intended. Then I right-hand-mouse context menu anywhere on the data grid and
choose the “Save As” option to get the save as screen. I then choose my options and parameters for this
screen and press OK to verify that it works correctly. Now I reopen the “Save As” dialog and this time
instead press the camera icon. That will open a dialog for creating a user defined “Action” to perform
this task – but not to run it. I now need to define some terms so you know what’s going on.
Toad defines the following terms:

Action - An atomic chunk of Toad functionality which has been encapsulated for the purpose of
executing, scheduling, sharing and building Toad Apps

App - One or more Actions designed to work in unison as a mini Toad Application

App Designer - The window used to create & manage Apps
So in this example I’ve 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 let’s open the App Designer to see the results we’ve accomplished.
I can now choose to run ort schedule that application. If I choose to run it, Toad is simply executing the
application within my currently running instance of Toad – behind the scenes it will execute the query
and perform a save as. But I won’t see anything flash by – just simply a run status indicator such as the
green completed shown here. If I now go into my CTemp directory – I’ll find that file as expected. If I
instead schedule this application, a wizard is invoked – and is shown below.
I have now created a Windows Task on my PC that will invoke (i.e. execute) Toad in command line mode
in my C:\Temp directory and pass the necessary parameters such that it will run this application – and all
its actions had it been multi-action. That’s it – nothing to learn like the old command line method.
So where can you do this – basically on any screen that has the camera icon at the bottom. The list is
growing as we speak – since it’s now a primary focus that everything In Toad should be an action. Plus,
what if I had not wanted to go into the actual screen, but rather would like to build the application and
its actions right there in the App Designer screen. That too is an option. The tabs along the right hand
side offer toolbar icons for the tasks for which we’ve already defined as actions. That list too is growing.
Now let me give you an example for a DBA, which will also introduce you to many other possibilities for
using the Toad Application Designer. In the Application below, I check my database to see if it’s up, if it is
I run a health check – which will email me the results, and if not, I’ll start the database first and then run
the health check. Hmmm – seems to me that the possibilities are near limitless 
Data Import/Export
Probably one of the most commonly performed development and test database tasks is to refresh data
for people to run their code against. For this – many people use the Oracle import and export utilities.
But you really cannot see into a dump file – other than to ask for a TOC (table of contents). Frankly,
that’s just not good enough. What I want is a tool something like WinZip – i.e. a utility to “peek” inside
the dump file and then maybe selectively choose what I want. Of course Toad solves this problem too
via the Export File Browser, available off the Main Menu->Database->Export->Export File Browser.
There’s really nothing else like it out there. Not only can I view the contents of the dump file via the
navigator tree-view on the left hand side (shown below), but I can see the DDL for that object and its
data under the tabs on the right hand side as well. So I can cut and paste the DDL if I like – to make sure
the objects exists before the import. I also can see the data in a standard Toad Data Grid. Did you catch
that handy tidbit? The data shows up in a standard grid – meaning I get all my right hand menu options
such as “Save As”, “Print”, “Row Count”, etc. Note that the export 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. Because once we’ve opened and thus parsed a file, Toad is smart enough not to have to do that
expensive process again – so even a 100GB dump file will open up quickly on the second and subsequent
usages.
Code Xpert
As developers, we all want to write better code. And as DBA’s, we all want to find any code that does
not fit the definition of better (i.e. find the needle in the haystack). Guess what – Toad can solve both
those dilemmas too via the Code Xpert.
Developers don’t always have time to perform formal code reviews. And even when they do, the code
review is only as good as that session’s participants. What’s needed is some way to automate and/or
streamline the process – while also adding consistency of results. Look at the silly code below. Wouldn’t
it be nice to get a review before showing this to my colleagues – and have them think even less of me 
Probably more realistic scenario would be to eliminate all the easily findable issues before going to a
more formal code review, such that I don’t squander key talents’ time addressing non-mission critical
mistakes. In fact, if the automated review is good enough – it might even suffice in some circumstances
thus saving the cost of the formal code reviews. That savings alone could be substantial just for the
person hours regained on coding versus reviewing. So how do we fix this horrible code shown below?
Toad offers a utility inside the editor called the Code Xpert. It’s basically like having a mentor review
your work at the push of a button. By merely switching to the Code Xpert tab near the editor screen
bottom and pressing the “Perform Code Review” button – I get output like that shown here:
Code Xpert has found and advises against using a GOTO. There are over one hundred programming rules
that defined by default – but Toad mercifully restricts to the top 20 as defined by industry experts . But
if you don’t like this predefined rule set (or any of the other predefined rule sets) – you have merely to
adjust which rules to check for your use. You can even create your own custom rule sets. But there’s
more. The reports tab will show several key items worth having access to: a CRUD matrix of the tables
referenced by that code, Software Engineering Institute (SEI) standard metrics (i.e. Halstead Complexity
Measure, MC Cabe’s Cyclomatic Complexity, Maintainability Index) for that code, plus a simplistic Toad
code rating (i.e. green, yellow or red) based upon those cumulative results from those standard metrics.
Furthermore, the Code Xpert will rate 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.
Now what if you’re the DBA simply trying to track down a performance problem somewhere amongst
the millions of lines of PL/SQL code in your database? Toad has a batch mode interface into Code Xpert
shown below for just for that very purpose – scan the code and tell me where to pay attention (i.e. find
the needle in the haystack). You also can use this utility to create project deliverables as to the overall
code quality. For government projects or consultants required to produce such items, batch mode Code
Xpert can be a life saver.
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. I’ve seen five line SELECT’s that take several hours to run and 100 line SELECT’s
that take just seconds to run. When you start regularly using more complex SQL features such as joins,
sub-select’s, correlated sub-queries, group by, having and order by – pretty soon the performance of a
query can become a daunting challenge. Now hopefully you found the problem query quickly via the
Code Xpert (from the prior section). But even if you did it the old fashioned way – at some point the task
at hand is to make the query from hell run faster. And if the query complexity is overly high, then this
just makes the task all the more harder. Again, Toad comes to your rescue. The SQL Optimizer in the
Toad Xpert Edition has the ability to either assist you with or automatically tune any query – no matter
how complex. Quest 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,
database structural changes (add/subtract indexes, partition database objects, move objects to different
tablespaces, etc). Once you’ve identified via SQL Optimizer all the possible scenarios that might result in
better performance, it can run them all and report back on the winner. In fact for lazy people like me, I
just enter SQL Optimizer and push two buttons: generate all the likely best re-writes and test them,
telling me the winner. So for practically no effort, even I can produce SQL code that’s guaranteed to be
the fastest possible. And I don’t even really have to explain explain-plans, outlines, hints or any other
advanced Oracle concepts. SQL Optimizer simply helps me to find the best code possible as quickly as
possible – regardless of my tuning and optimization skillset.
In Conclusion
I hope you found some of the above five topics interesting enough to warrant further inspection on your
part. I believe any and all of them can increase your productivity regardless of your role – as well as help
to achieve maximum performance for minimum investment in time and effort. We show these features
in even further detail in the webcast presentation by the same name (Toad Hidden Treasures). Plus our
Toad World web site offers numerous blogs, coffee bytes, papers and presentations to help you to get
the most from Toad.
Download