9
TOAD Tips and Tricks Quick Reference SQL Editor – SQL plus on Steroids! 1. SQL Recall Access previously run SQL by selecting F8. This will put a “Slide in slide out” SQL recall button on the left side of the Editor. The user can narrow the selections by adding to “Personal SQLs” or take it a step further by adding to “Named SQL” both of which are found under the SQL Editor menu option. To select Personal and Named SQL, click the drop down button on the far left of the recall window that says “Show” and change it from “all” to named or personal. 2. Table and Column Windows From the VIEW menu select the OBJECT PALLETT this will invoke a sliding/dockable window displaying Tables and Columns. Once these windows are slid into view, drag and drop functionality can be fully utilized. Another manner for retrieving table names is by selecting the first letter or letters of the table and hitting <CTRL . > To access a table description, leave the cursor on the table name and hit F4. 3. SQL Function Templates From the VIEW menu select the CODE SNIPPETS this will invoke a sliding/dockable window displaying code templates. A drop down let’s us see all of the different Function Types from which we can select templates. Drag and drop can also be utilized from this dockable window. 4. Make Code Statements TOAD supports 6 different languages, chosen through the Options menu, into which it can make code statements to be imbedded in source code. To take a SQL statement and automatically format it to be imbedded into a Java program, for example, we need to simply click the icon on the right side of the third icon bar, which has an arrow pointing from the letters “SQL” to what looks to be a note card. If moused over, it reads “Make a Non-SQL CODE Statement.” This will copy the current window’s statement to the clipboard in whichever language’s syntax the user has chosen. The next step is to paste the formatted SQL call into the code. From the options menu you can select JAVA, VB, Perl, C++, C#, or Delphi as the default. 5. Format Code To instantly transform chaotic, untidy code into easily managed aesthetically pleasing code by right clicking in the editor and selecting “Formatting tools” then choose “Format code.” Under the menu option “View” select Formatting Options to customize how the code will be formatted. 6. Auto Replace To access the auto replace functionality right click from the editor and select “Editing Options”. From there choose “Auto Replace” to set what the user wants replaced and with what to replace it. 7. Code Templates Right click from the SQL Editor and choose “Editing Options.” From there select Code Templates. TOAD provides many templates but the user can also add their own templates from here. To access the Templates from the SQL Editor simultaneously press CTRL and the Space Bar. The user can also memorize the shortcuts, type one and hit CRTL/Space to retrieve the Template.

TOAD Tips - Quick Reference

Embed Size (px)

Citation preview

Page 1: TOAD Tips - Quick Reference

TOAD Tips and Tricks Quick Reference SQL Editor – SQL plus on Steroids!

1. SQL Recall Access previously run SQL by selecting F8. This will put a “Slide in slide out” SQL recall button on the left side of the Editor. The user can narrow the selections by adding to “Personal SQLs” or take it a step further by adding to “Named SQL” both of which are found under the SQL Editor menu option. To select Personal and Named SQL, click the drop down button on the far left of the recall window that says “Show” and change it from “all” to named or personal.

2. Table and Column Windows From the VIEW menu select the OBJECT PALLETT this will invoke a sliding/dockable window displaying Tables and Columns. Once these windows are slid into view, drag and drop functionality can be fully utilized. Another manner for retrieving table names is by selecting the first letter or letters of the table and hitting <CTRL . > To access a table description, leave the cursor on the table name and hit F4.

3. SQL Function Templates From the VIEW menu select the CODE SNIPPETS this will invoke a sliding/dockable window displaying code templates. A drop down let’s us see all of the different Function Types from which we can select templates. Drag and drop can also be utilized from this dockable window.

4. Make Code Statements TOAD supports 6 different languages, chosen through the Options menu, into which it can make code statements to be imbedded in source code. To take a SQL statement and automatically format it to be imbedded into a Java program, for example, we need to simply click the icon on the right side of the third icon bar, which has an arrow pointing from the letters “SQL” to what looks to be a note card. If moused over, it reads “Make a Non-SQL CODE Statement.” This will copy the current window’s statement to the clipboard in whichever language’s syntax the user has chosen. The next step is to paste the formatted SQL call into the code. From the options menu you can select JAVA, VB, Perl, C++, C#, or Delphi as the default.

5. Format Code To instantly transform chaotic, untidy code into easily managed aesthetically pleasing code by right clicking in the editor and selecting “Formatting tools” then choose “Format code.” Under the menu option “View” select Formatting Options to customize how the code will be formatted.

6. Auto Replace To access the auto replace functionality right click from the editor and select “Editing Options”. From there choose “Auto Replace” to set what the user wants replaced and with what to replace it.

7. Code Templates Right click from the SQL Editor and choose “Editing Options.” From there select Code Templates. TOAD provides many templates but the user can also add their own templates from here. To access the Templates from the SQL Editor simultaneously press CTRL and the Space Bar. The user can also memorize the shortcuts, type one and hit CRTL/Space to retrieve the Template.

Page 2: TOAD Tips - Quick Reference

8. Script Debugger (Toad for Oracle Professional) -The Script Debugger window

provides a location where you can try out SQL scripts and statements in a debugging environment. You can load multiple scripts and each will open in its own data grid tab.

9. Code Xpert (Toad for Oracle Professional)- Acts just like Code Xpert for PLSQL, except applies to SQL Scripts. (See Procedure Editor topic 4)

10. Tune SQL Statement- (See page 4 for the Xpert Tuning Lab) Schema Browser - Tabular view of visual objects with add/delete/modify ability

1) Customize Tabs Customize tabular view by Right clicking in the white area of the object icon bar.

2) Favorites Add regularly accessed objects to the favorites tab by right clicking on the object and selecting Add to SB Favorites

3) Data View and modify a table’s data by selecting table from the object tabular view, and the DATA from the right side of the screen

a) Sort/Filter the data by selecting the icon resembling a funnel b) Save the data to a file format of your choice by right clicking in the data

grid and selecting Save As. This gives the choice of format and saving the data to a file or copying to the clipboard.

c) Create Insert Statements by right clicking the data grid and selecting create insert statement. It will save inserts on clip board to be run from SQL Editor.

d) Customize Layouts by dragging and dropping columns into select order. Fix a column or set of columns by right clicking and selecting fix current column. View only desired columns by right clicking and choosing select columns.

e) Master Detail Browser shows referential integrity at the record level. This feature is housed under the tools menu.

4) ER Diagram Access our table specific ERD by selecting the icon in the tables tab the represents 3 tables joined together. 5) Object History Quickly access objects previously used in a Schema Browser

session by clicking on the icon resembling a Sun Dial.

Page 3: TOAD Tips - Quick Reference

SQL Modeler - allows for building queries visually 1) Select Tables From the VIEW menu select the OBJECT PALLETT this will

invoke a sliding/dockable window displaying Tables and Columns. Select one, all or any subset in between of the tables or views necessary for the query and drag them into the workspace on the left.

2) View Joins Double click the links to view the joins. 3) Choose Columns Double click in the check boxes of the columns desired for the

query 4) Add Criteria The selected columns will appear in the navigation window on the

left side of the screen. Set up any added criteria such as sorts or where conditions, by dragging the appropriate column onto the appropriate action. (Make sure the nodes are opened for “Where” and “Order By”)

5) View Generated Query View the SQL by looking at bottom of the screen under the Generated Query tab. To modify this statement click the icon that says SQL and has a blue database symbol which is located on the second of the top two icon bars next to the ambulance

6) Run Generated Query Run the query with the F9 key or the green play button to return a data set.

7) Explain Plan View the explain plan by clicking on the ambulance icon on the second of the top two icon bars

Procedure Editor – Allows you to create and debug functions, procedures, & packages.

1) Customizing Procedure Template TOAD has templates for Procedures, Functions, Triggers and Packages, which are fully customizable. To modify a template select proc templates from TOAD options.

2) Debugger (Toad for Oracle Professional) – TOAD’s tool to help set breaks and view variables’ values.

a) Set Breaks To set breaks in the code leave the cursor on the line on which you wish the code to break and hit F5. Set conditional breaks by double clicking the break in the “Break and Watch view window.”

b) Add Watch To add a watch on a variable, leave the cursor blinking on the variable on which the watch is desired and click the eyeglasses icon.

3) Deposit values To explicate deposit a value into a variable, highlight the variable in the watch window and hit the calculator on the icon bar which, once moused over will read “Evaluate/Modify Watch”

a) Input Parameters To pass in parameters, click the “(…)” icon b) Run the code by hitting the yellow lightening bolt icon

Page 4: TOAD Tips - Quick Reference

4) Code Xpert (Toad for Oracle Professional)- Run your code through our code

review engine by clicking the icon featuring a database cylinder with a flag protruding from it. It is found on the last icon bar farthest to the right. It will pop up a pinnable window from which the user can run his/her code against a set of predefined rules. When run with TOAD Xpert, can scan SQL to tell if any statements are problematic and need tuning.

Tuning in TOAD (Xpert Package)

TOAD Xpert contains a comprehensive best of breed tuning solution which will identify problematic SQL, Optimize statements, offer virtual index alternatives and best practices. Wherever one can access SQL in TOAD, one can invoke a tuning session applicable to that statement by simply selecting the “Tune the Current SQL Statement” icon represented by a yellow beaker and a tuning fork. This document will discuss tuning a statement from the SQL Editor. Tuning Current Statement from SQL Editor When handling a problematic SQL statement in the SQL Editor in TOAD (Code Xpert will identify problematic statements from the editor), it is very easy to move the statement into our tuning lab. On the same icon bar as the Green run arrow, you will the see the TUNING icon. Again, it is the Yellow Beaker with the Tuning fork (Found next to the ambulance). Explain Plan- TOAD’s tuning offers a simplified Explain Plan which is automatically generated when a statement is moved into the Tuning area. The TOAD Tuning Explain Plan displays a numbered layout to show the order of operations. An English breakdown as to what each step of the explain means can be found right below the plan itself. Optimize Statement- This is the “make it go faster” button. It is an icon represented by a gray tuning fork in the top left of the tuning window. This will rewrite the statement up to as ways as it can be written and then return scenarios for those statements with distinct execution plans.

-Select alternatives to run- Typically the tool will generate a vast number of rewrites. The user selects which of the rewrites to run and compare statistics. From the SQL Details pane, right click to deselect all then check the alternatives desired to run. -Compare Scenarios- Upon completion of the selections’ running, click the Compare Scenarios button on the left side. This will allow a side-by-side view your rewrites and original code and statistics.

Page 5: TOAD Tips - Quick Reference

Indexes – The icon to right of the Optimize icon displays the tuning fork atop a green background is the “Generate Virtual Index” icon. It will analyze all possible new scenarios for indexes that could be created to influence the statement’s performance. Best Practices – The light bulb icon will invoke best practices which analyzes the tables, indexes, statistics, and explain plans then offers recommended best practices for improving the SQL’s performance. All of the Above – To the right of the Light bulb is an icon which will run all of the above mentioned functionality. Identify Problematic SQL- Identify problematic SQL by scanning DB objects and source code for embedded SQL and sending that SQL through the engine to determine what of the scanned code is problematic.

a. Launch SQL Scanner- On the far right of the Tuning icon bar, there is an icon with the beaker and tuning fork as well as a green arrow; Open SQL Scanner. Choose the icon which resembles a piece of red lined paper.

b. Create a group- From the Group Manager window, select CREATE and

then name your program group. Chose the group on which you’d like to work, then hit OPEN.

c. Add Jobs- Click next to select any DB Object folders or specific objects which you would like to scan by clicking on the Database Objects box. Select any source code you would like to scan by choosing the Source Codes box and clicking on the blue + to add files from a file system.

d. Click OK Scan Code- From the Job manager Click the icon with a green arrow (play button) and “S”. This will scan the code for valid and problematic SQL. Find the problematic SQL you’d like to work on, and double click. This brings you into a SQL Viewer Screen where you can see why it was flagged as problematic

Page 6: TOAD Tips - Quick Reference

Miscellaneous Tools HTML Schema Doc Generator - Want an easy way to document your schema definitions? Toad can easily create the HTML base to allow convenient browsing of schemas... simply select TOOLS->HTML SCHEMA DOC GENERATOR, select the schemas you wish to include, choose your desired options, and press the 'execute' button! Compare Data Ever find yourself in a situation where you needed to compare data content of two similar tables on different schemas or databases? Toad allows you several convenient ways to do this. Choose TOOLS->COMPARE DATA choose the source and target objects, and follow the wizard prompts. Optionally, you can right-click a table in the Schema Browser, and choose "Compare Data". Master Detail Browser Navigating the content of two or more related tables can be very time-consuming and confusing. Choose TOOLS->Master-Detail browser for Toad to bring up one panel that allows you to choose your related tables, and drill into the data logically from one table to another. TOAD Security TOAD respects all the security and privileges that are set up in Oracle. Additionally, you can restrict individuals or groups of users from accessing some TOAD features using Toad Security. You can make TOAD “read-only” for individuals or groups of users. For more information please email [email protected]. Auditing Lots of companies don't use the internal audit features of Oracle. Or, when they do use them, they turn on everything and realize there is so much output to analyze they turn it all off. Firewalls and other security tools are a common way to determine if the network or operating system is being misused or abused. Why not audit what users are doing to the "key asset" of an organization, the data. TOAD’s audit features can help you connect to Oracle audits and help detect unauthorized access and internal abuse of the data held in the database. TOAD 8.5 (and later) has features to help you secure your database so that you can view audit trails and logs that help with maintaining compliance. A complete TOAD auditing white paper is available from Quest. Project Manager The Project Manager is used to build shortcut lists to the DB Objects, external files, and reference To-Do lists to accomplish project oriented tasks. This provides a quick link to work with files and DB Objects that are required to perform the task instead of browsing through the Schema Browser. The Project Manager is activated by clicking on the Blue Book Button in the TOAD Toolbar. This will open and dock the window on the desktop. Click on the pin button to make it become a slide-out window so that it takes up less room and is only expanded as needed. Access Knowledge Base Increase productivity by answering of finding 70-80% of questions faced every day by Oracle Professionals. Get reliable, accurate advice based on industry experts. Includes Oracle error message quick look-up. Simply click on the Knowledge Base Icon (blue button- person with a light bulb inside head) Help TOAD has a very powerful Help section. Click on HELP > CONTENTS. Beginners will want to browse through TOAD BASICS while intermediate and advanced users will want to review MAIN TOAD FEATURES.

Page 7: TOAD Tips - Quick Reference

Shortcut Keys for TOAD (Excerpted from TOAD Help)

F1 Windows Help File

F2 Toggle Full screen Editor

F3 Find Next Occurrence

<SHIFT> <F3> Find Previous Occurrence

F4 Describe Table, View, Proc, Funct,

or Package in popup window

F5 Sets or Deletes a Breakpoint in the Stored Proc editor for PL/SQL debugging

F6 Toggle between SQL Editor and Results Grid

F7 Clear All Text. If you have the PL/SQL Debugger module, F7 is reserved for the "Trace Into" function"

F8 Recall previous SQL statement in the SQL editor (Stores last 100), "Step Over" in the Stored Proc editor for PL/SQL debugging.

F9 Execute statement in the SQL editor, Compile in the Stored Proc editor

<CTRL> F9 Verify statement without execution (parse) in the SQL editor, Set Parameters in the Stored Proc editor for PL/SQL debugging.

<SHIFT> F9 Execute current statement at cursor in the SQL editor, Execute Current Source in the Stored Proc editor for PL/SQL debugging.

Page 8: TOAD Tips - Quick Reference

F10 Popup Menu

F11 Run (continue execution) in the

Stored Proc editor for PL/SQL debugging

F12 Run to cursor in the Stored Proc editor for PL/SQL debugging

<CTRL> A Select All Text

<CTRL><ALT>B Display the PL/SQL Debugger Breakpoints window

<CTRL> C Copy

<CTRL><ALT>D Display the PL/SQL Debugger DBMS Output window

<CTRL> E Execute Explain Plan on the Current Statement

CTRL><ALT>E Display the PL/SQL Debugger Evaluate/Modify window

<CTRL> F Find Text

<CTRL> G Goto Line

<CTRL> L Converts Text to Lowercase

<CTRL> M Make Code Statement

<CTRL> N Recall Named SQL Statement

<CTRL> O Opens a Text File

<CTRL> P Strip Code Statement

<CTRL> R Find and Replace

<CTRL> S Save File

SHIFT> <CTRL> S Save File As

Page 9: TOAD Tips - Quick Reference

<CTRL> T Columns Dropdown

<CTRL> U Converts Text to Uppercase

<CTRL> V Paste

CTRL><ALT>W Display the PL/SQL Debugger

Watches window

<CTRL> X Cut

<CTRL> Z Undo Last Change

<CTRL>. Display popup list of matching tablenames

<SHIFT> <CTRL> Z Redo Last Undo

<ALT> <UP> Display Previous Statement

<ALT> <DOWN> Display Next Statement (after <ALT> <UP>)

<CTRL><HOME> In the data grids, goes to the top of the recordset

<CTRL><END> In the data grids, goes to the end of the recordset

<CTRL><SPACE> Completely expand dependency tree views

<CTRL><TAB> Cycles through the collection of MDI Child windows

<CTRL><ENTER> Execute current SQL (same as <SHIFT>F9)

<CTRL><.> Auto-completes table names