toad user's guide

260
Toad ® for Oracle ® User’s Guide Version 8.5

Upload: cthaocollege22224910

Post on 15-Dec-2015

57 views

Category:

Documents


2 download

DESCRIPTION

TOAD user guide

TRANSCRIPT

  • Toad for OracleUsers Guide

    Version 8.5

  • Copyright Quest Software, Inc. 2005. All rights reserved.

    This guide contains proprietary information, which is 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.

    WARRANTY

    The information contained in this document is subject to change without notice. Quest Software makes no warranty of any kind with respect to this information. QUEST SOFTWARE SPECIFICALLY DISCLAIMS THE IMPLIED WARRANTY OF THE MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Quest Software shall not be liable for any direct, indirect, incidental, consequential, or other damage alleged in connection with the furnishing or use of this information.

    TRADEMARKS

    Quest and Toad are trademarks of Quest Software, Inc. Other trademarks and registered trademarks used in this guide are property of their respective owners.

    World Headquarters8001 Irvine Center DriveIrvine, CA 92618www.quest.comemail: [email protected]. and Canada: 949.754.8000

    Please refer to our Web site for regional and international office information.

    Toad for Oracle Users GuideUpdated - April 2005Software Version - 8.5

  • CONTENTS

    CHAPTER 1INTRODUCTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

    TOAD OVERVIEW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

    CHAPTER 2LOGON AND LOGOFF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

    LOGIN SCREEN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6CONNECTING TO PERSONAL ORACLE. . . . . . . . . . . . . . . . . . . .11END CONNECTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11

    CHAPTER 3SCHEMA PREPARATION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13

    SERVER SIDE INSTALLATION WIZARD . . . . . . . . . . . . . . . . . . .14EXPLAIN PLAN TABLE . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14

    CHAPTER 4BASICS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .15

    MOUSE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .16KEYBOARD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18HOTKEYS - ADDING/ALTERING . . . . . . . . . . . . . . . . . . . . . . .19RIGHT-CLICK MENUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . .20WINDOW BAR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .20MAIN TOOLBAR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .21

    CONFIGURE TOAD OPTIONS. . . . . . . . . . . . . . . . . . . . . .21

    SAVE TOAD OPTIONS . . . . . . . . . . . . . . . . . . . . . . . . .21

    OFFLINE TEXT EDITOR . . . . . . . . . . . . . . . . . . . . . . . . .22

    CONFIGURE/EXECUTE EXTERNAL TOOLS . . . . . . . . . . . . . .23

    PROJECT MANAGER . . . . . . . . . . . . . . . . . . . . . . . . . . .23

    OBJECT PALETTE . . . . . . . . . . . . . . . . . . . . . . . . . . . .25

    CUSTOMIZE (TOOLBARS AND MENUS) . . . . . . . . . . . . . . . . . . .26TOOLBAR OPTIONS . . . . . . . . . . . . . . . . . . . . . . . . . . .27

    MENU SHORTCUT CUSTOMIZATION WINDOW . . . . . . . . . . . . . . .29DOCKABLE WINDOWS. . . . . . . . . . . . . . . . . . . . . . . . . . . . .29

    CHAPTER 5i

  • Toad for Oracle

    SQL EDITOR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31

    OVERVIEW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .33SQL EDITOR TOOLBAR . . . . . . . . . . . . . . . . . . . . . . . . . . .34FORMAT CODE TOOLBAR. . . . . . . . . . . . . . . . . . . . . . . . . . .34SOURCE CONTROL TOOLBAR . . . . . . . . . . . . . . . . . . . . . . . .34SQL RECALL TOOLBAR. . . . . . . . . . . . . . . . . . . . . . . . . . . .34CURRENT SCHEMA TOOLBAR . . . . . . . . . . . . . . . . . . . . . . . .34SHORTCUT KEYS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .35USING THE SQL EDITOR . . . . . . . . . . . . . . . . . . . . . . . . . .39

    SELECTING A TABLE TO EDIT . . . . . . . . . . . . . . . . . . . . .39

    NAVIGATOR PANEL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .40SQL RESULTS PANEL . . . . . . . . . . . . . . . . . . . . . . . . . . . .40

    DATA TAB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .40

    EXPLAIN PLAN TAB . . . . . . . . . . . . . . . . . . . . . . . . . . .46

    AUTO TRACE TAB . . . . . . . . . . . . . . . . . . . . . . . . . . . .47

    DBMS OUTPUT TAB . . . . . . . . . . . . . . . . . . . . . . . . . .47

    SCRIPT OUTPUT . . . . . . . . . . . . . . . . . . . . . . . . . . . . .47

    QUERY VIEWER . . . . . . . . . . . . . . . . . . . . . . . . . . . . .48

    CODE SNIPPETS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .49MAKE CODE STATEMENT AND STRIP CODE STATEMENT . . . . .49

    EXPLAIN PLAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .52EXPLAIN PLAN TREEVIEW . . . . . . . . . . . . . . . . . . . . . . .54

    RECALL AND ADD SQL . . . . . . . . . . . . . . . . . . . . . . . .57

    OPTIONS FOR THE SQL EDITOR . . . . . . . . . . . . . . . . . . . . . .61SQL OPTIONS PAGE . . . . . . . . . . . . . . . . . . . . . . . . . .61

    MAKE CODE PAGE. . . . . . . . . . . . . . . . . . . . . . . . . . . .63

    SCRIPT OPTIONS PAGE. . . . . . . . . . . . . . . . . . . . . . . . .63

    EXECUTING STATEMENTS . . . . . . . . . . . . . . . . . . . . . . . . . .65EXECUTE SQL SCRIPTS . . . . . . . . . . . . . . . . . . . . . . . .67

    TABLE/VIEW ALIASES . . . . . . . . . . . . . . . . . . . . . . . . .73

    CONFIGURING THE EDITOR . . . . . . . . . . . . . . . . . . . . . . . . .75USER CONFIGURABLE SYNTAX COLOR HIGHLIGHTING. . . . . . .75

    BOOKMARKS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .78ii

  • Contents

    USER DEFINED KEYSTROKES FOR COMMON EDITING COMMANDS 78

    AUTO REPLACE SUBSTITUTIONS . . . . . . . . . . . . . . . . . . .79

    CODE COMPLETION TEMPLATES. . . . . . . . . . . . . . . . . . . .80

    UNDO/REDO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .81

    COMMENT CODE BLOCK . . . . . . . . . . . . . . . . . . . . . . . .81

    UNCOMMENT CODE BLOCK . . . . . . . . . . . . . . . . . . . . . .81

    LOCATE CLOSING PARENTHESIS (FIND CLOSING BLOCK) . . . .82

    FIND, FIND NEXT, FIND PREVIOUS, AND REPLACE . . . . . . . .82

    SHOW ALL FOLLOWING A SEARCH . . . . . . . . . . . . . . . . . .83

    CONFIGURABLE PRINT OPTIONS . . . . . . . . . . . . . . . . . . .83

    EDITOR OPTIONS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .84GENERAL OPTIONS . . . . . . . . . . . . . . . . . . . . . . . . . . .85

    HIGHLIGHTING. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .91

    KEY ASSIGNMENTS . . . . . . . . . . . . . . . . . . . . . . . . . . .94

    AUTO REPLACE . . . . . . . . . . . . . . . . . . . . . . . . . . . . .95

    CODE TEMPLATES . . . . . . . . . . . . . . . . . . . . . . . . . . . .98

    RIGHT-CLICK MENU . . . . . . . . . . . . . . . . . . . . . . . . . . . . .100OPTIONS FOR THE EDITORS. . . . . . . . . . . . . . . . . . . . .101

    SCRIPT DEBUGGER . . . . . . . . . . . . . . . . . . . . . . . . . . . . .106CODEXPERT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .106

    SQL SCAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .106

    CHAPTER 6DATA GRIDS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .107

    OVERVIEW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .108RIGHT-CLICK MENU . . . . . . . . . . . . . . . . . . . . . . . . . . . . .108SORT OPTIONS WINDOW . . . . . . . . . . . . . . . . . . . . . . . . .118CALCULATOR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .119DATA GRIDS - DATA OPTIONS . . . . . . . . . . . . . . . . . . . . . .120DATA GRIDS - VISUAL OPTIONS . . . . . . . . . . . . . . . . . . . . .123REPORT LINK DESIGNER. . . . . . . . . . . . . . . . . . . . . . . . . .128

    OPTIONS TAB . . . . . . . . . . . . . . . . . . . . . . . . . . . . .128

    COLORS TAB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .129

    FONTS TAB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .130iii

  • Toad for Oracle

    BEHAVIORS TAB . . . . . . . . . . . . . . . . . . . . . . . . . . . .130

    MISCELLANEOUS TAB . . . . . . . . . . . . . . . . . . . . . . . . .130

    CHAPTER 7PROCEDURE EDITOR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .131

    OVERVIEW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .133PROCEDURE EDITOR TOOLBARS . . . . . . . . . . . . . . . . . . . . .133SHORTCUT KEYS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .134PARAMETER HINTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . .136USING THE PROCEDURE EDITOR . . . . . . . . . . . . . . . . . . . . .136NAVIGATOR TREE BUTTONS . . . . . . . . . . . . . . . . . . . . . . . .140OPTIONS FOR THE PROCEDURE EDITOR . . . . . . . . . . . . . . . . .141RIGHT-CLICK MENU . . . . . . . . . . . . . . . . . . . . . . . . . . . . .144DBMS OUTPUT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .145SOURCE CODE MANAGEMENT . . . . . . . . . . . . . . . . . . . . . . .147TEAM CODING . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .150PL/SQL DEBUGGER . . . . . . . . . . . . . . . . . . . . . . . . . . . .152

    TOOLTIP FEATURE FOR VARIABLES . . . . . . . . . . . . . . . . .154

    THE STATUS PANEL INDICATORS. . . . . . . . . . . . . . . . . .154

    THE DOCKABLE WINDOWS . . . . . . . . . . . . . . . . . . . . .155

    PREPARING PL/SQL CODE FOR PRODUCTION . . . . . . . . . .155

    CHAPTER 8SCHEMA BROWSER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .157

    OVERVIEW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .159USING THE SCHEMA BROWSER . . . . . . . . . . . . . . . . . . . . . .160OPTIONS FOR THE SCHEMA BROWSER. . . . . . . . . . . . . . . . . .166OBJECTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .177REFRESH OPTIONS . . . . . . . . . . . . . . . . . . . . . . . . . . . . .178CUSTOM QUERIES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .179FOREIGN KEY LOOKUP . . . . . . . . . . . . . . . . . . . . . . . . . . .180TABLES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .181

    OBJECTS PANEL . . . . . . . . . . . . . . . . . . . . . . . . . . . .183

    DETAILS PANEL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .190VIEWS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .197SYNONYMS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .197iv

  • Contents

    PROCEDURES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .198TRIGGERS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .199INDEXES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .200CONSTRAINTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .200SEQUENCES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .201JAVA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .201DB LINKS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .201USERS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .202JOBS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .202TYPES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .202QUEUE TABLES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .203QUEUES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .203CLUSTERS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .203FAVORITES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .203

    CHAPTER 9OTHER FEATURES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .205

    QUEST SCRIPTRUNNER. . . . . . . . . . . . . . . . . . . . . . . . . . .207LAUNCHING QUEST SCRIPTRUNNER FROM COMMAND LINE . .209

    COMMANDS SUPPORTED . . . . . . . . . . . . . . . . . . . . . . .210

    SQL MODELER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .211SQL MODELER OPTIONS . . . . . . . . . . . . . . . . . . . . . .220

    CODE ROAD MAP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .222ER DIAGRAM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .223

    CREATE/ALTER TABLE . . . . . . . . . . . . . . . . . . . . . . . . . . .224CREATE TABLE. . . . . . . . . . . . . . . . . . . . . . . . . . . . .224

    ALTER TABLE . . . . . . . . . . . . . . . . . . . . . . . . . . . . .225

    TOAD REPORTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .226HTML SCHEMA DOC GENERATOR . . . . . . . . . . . . . . . . . . . .227NETWORK UTILITIES . . . . . . . . . . . . . . . . . . . . . . . . . . . .230TOAD SECURITY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .234SESSION BROWSER. . . . . . . . . . . . . . . . . . . . . . . . . . . . .236JAVA FEATURES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .237OPTIONAL QUEST DBA MODULE . . . . . . . . . . . . . . . . . . . . .238

    DBA WINDOWS . . . . . . . . . . . . . . . . . . . . . . . . . . . .238v

  • Toad for Oracle

    SCHEMA BROWSER AND CREATE MENU . . . . . . . . . . . . . .240

    VIEW TABLESPACES . . . . . . . . . . . . . . . . . . . . . . . . .241

    CODE ROAD MAP AND ER DIAGRAM . . . . . . . . . . . . . . .241

    FLAT FILE EXPORT WINDOW. . . . . . . . . . . . . . . . . . . . .241

    KNOWLEDGE XPERT FOR ORACLE ADMINISTRATION . . . . .241

    CHAPTER 10QUESTIONS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .243

    QUESTIONS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .244TOAD HELP. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .244CUSTOMER SUPPORT . . . . . . . . . . . . . . . . . . . . . . . . . . . .245

    INFORMATION DISPLAYED . . . . . . . . . . . . . . . . . . . . . .246vi

  • Introduction

    Toad Overview

    1

  • Toad for Oracle

    Toad OverviewToad is a powerful low-overhead tool built around an advanced SQL and PL/SQL editor. It was designed from the developer's perspective, and the result is an easy to use, fast, and effective interface. The GUI browsers provide quick access to database objects.

    You don't have to be a PL/SQL expert to access database objects when you're using Toad. You can view the Oracle Dictionary, tables, indexes, stored procedures, and more-- all through a multi-tabbed browser.

    PL/SQL script writers can use the advanced editing features to save time and increase productivity. Code can be created from shortcuts and code templates. You can even create your own code templates.

    Use Toad to:

    Create, browse, or alter objects (tables, views, indexes, etc.) including Oracle8 TYPE objects

    Graphically build, execute, and tune queries

    Edit, debug, and profile "stored procedures" including procedures, functions, packages, and triggers

    Search for objects

    Find and fix database problems with constraints, triggers, extents, indexes, and grants

    Manage your most common DB tasks from one central window

    Create HTML docs for any schemas, complete with links and customizable for content and style

    This guide is a how-to and reference for new users and users already familiar with Toad. The guide does not cover every Toad window, option, and function. The guide covers the following major windows:

    SQL Editor

    Procedure Editor

    Schema Browser2

  • Introduction

    Once you are comfortable navigating around a few of these windows you'll discover that the other Toad windows have a similar design. The manual also covers the following major topics:

    Logon/logoff

    Navigation and shortcuts

    The Toad for Oracle folder is referred to in this document as the Toad folder.

    Note that this User's Guide was prepared in April 2005. New or changed Toad features since April 2005 are not reflected in this version of the guide. Refer to Toad Help for the latest information.

    Colors are presented in the PDF. The printed version of the Users Guide is in black and white, so the color differences are not always distinguishable.

    For details on installing and uninstalling Toad, refer to the Getting Started Guide

    For details on the new features of Toad for Oracle 8.5, refer to Toad Help - Whats New. 3

  • Toad for Oracle4

  • Logon and Logoff

    Login Screen

    Connecting to Personal Oracle

    End Connection

    2

  • Toad for Oracle

    Login ScreenWhen you start Toad a Login screen displays. The screen lists your previous connections (user, server, and the date and time of the connection). Option boxes next to each connection let you check Auto Connect, Save Password, and Favorite.

    You can create a new connection to Oracle or select from a list of previous connections. All checked connections in the Autoconnect Column are automatically connected each time you start Toad.

    The date format comes from the workstation setting in Settings | Control Panel | Regional Settings | Date | Short date style option.

    Server Login

    You get to this dialog via the File | New Connection menu item or when Toad starts up.

    You can create a new connection to Oracle or select from a list of previous connections. Toad will fill the database dropdown with the names of previous sessions and any aliases in TNSNAMES.ORA.

    To create a new connection

    1. Type the name of the database in the dropdown combo box labeled Database. The server name you use must have an entry in the TNSNAMES.ORA file.

    2. Type the name of the USER in the textbox labeled User/Schema.

    3. Type the PASSWORD for the user in the textbox labeled Password. Asterisks will display instead of characters as you type.

    4. Click OK

    OR

    Press .

    To use a previous connection

    If the View | Options| Oracle | Save passwords for Oracle Connections option is checked

    THEN

    You can double-click a previous connection from the list in the left panel to automatically logon. 6

  • Logon and Logoff

    Otherwise, follow these steps.

    1. Select a previous connection from the list in the left panel.

    2. Type in the Password.

    3. Click OK or press .

    Toad saves the USER/DATABASE combinations between Toad sessions, but does not save the password.

    If the option is unchecked then the Save Pwd? column will display in the previously used connections grid. If you check the column the password is saved for the respective connection in the Login Grid.

    To delete a previous connection

    1. Select a connection from the Server, User, Last Connect list.

    2. Press the key.

    If you are having trouble running Toad with Personal Oracle 8.1.5

    If you are using Toad with Personal Oracle 8.1.5 or later and receiving errors like "No Listener" try the following:

    1. Open a Command Prompt.

    2. Type "lsnrctl" and

    3. Type the command "start"

    DO NOT ENABLE THE Save passwords for Oracle connections OPTION UNLESS YOU HAVE A SECURE ENVIRONMENT.7

  • Toad for Oracle

    Database dropdown

    The database dropdown supports multiple aliases for tnsnames.ora entries.

    The home that is selected by default in the dropdown at Toad startup is determined in the following order

    1. If an Oracle client DLL is specified as a command line parameter when launching Toad (for example TOAD.exe OCIDLL=C:\Oracle\Ora92\bin\oci.dll).

    2. The Toad default home

    3. The Oracle default home as determined by Oracles Home Selector

    If the OCIDLL parameter is used then the Home dropdown is disabled, because every connection will be made with this home regardless of what selection is made in the dropdown

    If LOCAL and ORACLE_SID are set for home, LOCAL is used first.

    If you do not specify a database from the dropdown list of databases, then the ORACLE_SID for the selected home is used. If there is no ORACLE_SID value and you do not specify a database in the dropdown, then no connection can take place.

    Operating System Authentication

    Toad can accept logins where the operating system validates the user and password. Select the database alias and leave the Username and Password textboxes empty. Oracle will prefix your workstation login and attempt a login. To configure this on the server side, the init.ora initialization parameters file must have:

    remote_os_authent = true

    os_authent_prefix = "OPS$"

    or whatever prefix you select.

    For example, Joe Smith logs onto the ORA805 database, enters "ORA805" in the Database textbox, and leaves Username and Password empty. His NT login is "JSMITH", which gets prefixed with "OPS$" giving a username of "OPS$JSMITH." Oracle attempts a login and Toad starts up.

    The next time you bring up the Server Login window, any previous logins that were O/S authentication logins will have username = "EXTERNAL". You don't need to type over the word EXTERNAL in the username textbox when reconnecting.8

  • Logon and Logoff

    You can use Oracle usernames without passwords in Toad. Whatever you enter in Database, Username, and Password boxes are passed to the database. If the database permits default passwords, you can connect.

    Connect using dropdown drilldown button

    This button opens the Oracle Home Editor window which shows all Oracle Homes. It also lets you see which Oracle Homes are valid installs. The information can be copied to the clipboard and pasted into an email for technical support issues.

    You can edit SID, NLS_LANG, and SQLPATH by double-clicking or via the right-click menu.

    If a SQL*Net entry is not valid, you can click the Advice button for suggestions.

    Make this the Toad default home

    Check this check box to make the home selected in the dropdown the Toad default home. Uncheck the check box to remove that home as the Toad default home.

    If you are upgrading to version 8.5 and you had your Toad default home previously set, youll have to reset it on the first execution of Toad 8.5. After that, the default home feature will work as expected.

    SQLNet Editor link

    This lets you set SQLNET.ORA parameters on the SQLNet editor screen. You can click View File and manually add/edit entries. A Make Settings Editable check box lets you make the screen editable. Clicking OK will save the changes to SQLNET.ORA. Create Backup File and Restore Backup File buttons on the SQLNET Editor screen let you create backups and restore backups from that screen.

    A green check next to the SQLNet Editor link indicates that a SQLNET.ORA file has been found for that home. A red X indicates that the file cannot be found.

    A red lock indicates the file (SQLNET.ORA) is read only.

    TNSNames Editor link

    This opens the TNSNames editor preloaded with the TNSNAMES.ORA file for the selected home.9

  • Toad for Oracle

    A green check next to the link indicates that the TNSNAMES.ORA file has been found for that home. A red X indicates that the file cannot be found.

    A red lock indicates the TNSNAMES.ORA file is read only.

    The TNSNames Editor supports multiple aliases. To add/edit entries that contain multiple aliases, type each alias separated by either a space or a comma in the Name:edit box.

    Refresh button

    This refreshes the previously used connection info for the left pane of the login window, the list of databases from the tnsnames for the database dropdown, and all of the home information from the registry/hard disk for the home selection dropdown.

    Save Passwords for Oracle Connections

    One of the Toad options is Save Passwords for Oracle Connections. The default for this option is unchecked. When unchecked, Toad puts in the username for the password. When checked, the password is saved in CONNECTIONS.INI. All passwords are encrypted.

    Before you check the Save passwords for Oracle Connections box, be sure you work in a secure environment where your CONNECTIONS.INI file will not fall into the wrong hands.

    To turn on the Save Passwords for Oracle Connections option

    1. Go to View | Options | Oracle.2. Click Save Passwords for Oracle Connections to check that

    option.

    3. Either quit Toad and restart

    OR

    Click the Save All Options button in the main toolbar. 10

  • Logon and Logoff

    Connecting to Personal OracleIf you are having trouble connecting to Personal Oracle or creating a SQL*Net alias try one of the following four entries for the database name on the Toad login window:

    2:

    BEQ-LOCAL

    LOCAL

    TCP-LOOPBACK

    For Schema/Passwords try one of the following pairs:

    DEMO/DEMO

    SCOTT/TIGER

    SYS/CHANGE_ON_INSTALL

    SYSTEM/MANAGER

    End ConnectionYou might want to close a connection without exiting Toad.

    To close a specific connection without exiting Toad

    1. Go to the File | End Connection menu.2. A popup window lists one or more sessions.

    3. Click the session you want to end.

    4. Click OK.

    All windows associated with that session are closed. If you have any Prompt to save before close options on, you will be prompted to save the editor contents so that they are not discarded.

    Toad also has an End All Connections option, accessed from the File menu, which will close all connections.11

  • Toad for Oracle12

  • Schema Preparation

    Server Side Installation wizard

    Explain Plan table

    3

  • Toad for Oracle

    Server Side Installation wizardDuring the installation you had the opportunity to install the server side objects for Toad via the Server Side Installation wizard. The wizard also lets you remove or update the objects. You can access the wizard while in Toad from the Tools menu. In order to install server side objects, you will need to have access to either the account for the Toad user, the account for the schema where you are installing them, or an account with the DBA role.

    The Server Side Installation wizard is discussed in detail in the Getting Started Guide.

    Explain Plan table

    If you do not create the tables needed for storage and retrieval of Explain Plans which you can do automatically via the Server Side Installation wizard, Toad will not display previous Explain Plan results. Explain Plan will still function on the SQL Edit window providing you specify PLAN_TABLE on the options window rather than Toad_PLAN_TABLE. If you decide NOT to store previous Explain Plan results, you should disable the option Save previous Explain Plan results on the View | Options | Oracle page.

    By default, Toad uses the user name plus the date and time to generate a unique statement id for the Explain Plan. (You can change the user name Toad uses for Explain Plan via the View | Options | Oracle | User Name for Explain Plan textbox.) If the user has a longer than normal user name, you might need to expand the Statement_ID column of the Plan table.

    On the View | Options | Oracle page, you can specify the name of the Explain Plan table that Toad should utilize. If you change the default setting from Toad_PLAN_TABLE to PLAN_TABLE, Toad will use your existing table, and you do not have to create the Toad table. On the other hand, if you still do not execute the Toad scripts, you will not be able to recall previous Explain Plan results.14

  • Basics

    Mouse

    Keyboard

    Hotkeys - adding/altering

    Right-click menus

    Window Bar

    Main Toolbar

    Customize (toolbars and menus)

    4 Menu Shortcut Customization window

    Dockable windows

  • Toad for Oracle

    MouseToad is designed to be used with a mouse. In addition to left-clicking on items, the right-click button displays right-click menus. Right-click menus are discussed in the Right-click menu section of this chapter.

    Drill Down buttons

    Drill down buttons indicate another level of information. Click the drill down button to drill down another layer, which is usually another window.

    Check boxes

    You will find check boxes throughout Toad. The program is designed to be flexible, and with check boxes you control how Toad looks and functions. You can check multiple items in a check box list. Options you've set in one check box might affect options in another check box.

    To place a check in a check box or remove a check from a check box

    1. Click in the check box area or label area

    OR

    Tab to the area with the check boxes and press the up and down arrow keys until your option is highlighted.

    2. Press the space bar.16

  • Basics

    Dropdown lists

    Dropdown lists are used throughout the Toad screens. The down arrow activates a dropdown menu from which you can choose an item.

    Types of Message Boxes

    Toad uses the industry standard symbols for its four types of message boxes.

    i This indicates an information box.

    ?This indicates a question box that requires a decision from you.

    X This indicates a stop message

    ! This indicates an exclamation (very important) message.17

  • Toad for Oracle

    KeyboardYou can use the keyboard for navigation and selection.

    TAB

    The TAB key lets you advance the cursor forward from one area of a window to another area. The first item in the area you tab to will highlight.

    For textboxes, you can TAB to the textbox, and the text cursor displays ready for you to type.

    UP/DOWN ARROWS

    The UP ARROW and DOWN ARROW let you move your cursor up and down the items or list of whatever area your cursor is positioned in. In a dropdown list the UP and DOWN ARROWS scroll through the choices in the list.

    LEFT/RIGHT ARROWS

    The LEFT ARROW and RIGHT ARROW let you move left and right across a list of radio button choices. Once you reach your choice, TAB to move out of the area (or click outside of the area with your mouse), and your choice remains. You can also use the UP/DOWN arrow keys to move through the radio button choices.

    For the Expand and Collapse buttons the LEFT ARROW collapses the list and the RIGHT ARROW expands the list.

    You can also activate Expand and Collapse buttons using the and keys on the numeric keypad. The plus sign "+" expands the list and the minus sign "-" collapses the list. For hierarchy lists, the multiplication sign "*" expands to all levels.

    SPACEBAR

    The spacebar lets you check and uncheck check boxes or click buttons with focus.

    ENTER

    ENTER is similar to a mouse-click. It activates whatever button has focus. For example, if you to a CANCEL button and press , you will cancel your choices and exit the window. Pressing on buttons with focus also clicks the buttons.

    ESC18

    ESC cancels most modal dialogs.

  • Basics

    Not Accessible by Keyboard

    Toad was designed for a mouse, and some areas of Toad can only be accessed by using the mouse.

    For example, you cannot tab to a drill down button. You have to click the drill down button to bring up its associated window.

    Hotkeys - adding/altering The Editor Options Dialog list of key assignments contains a list of the basic editing functions. , , and are mapped to copy (C), paste (V), and cut (X) automatically.

    When you highlight a command, you can alter the key assigned to that command OR add an additional key. All commands allow for two-part keystrokes; for example, Control-K, 0 for the command "set Bookmark 0."

    To set the command for "Bookmark0" to "Control-K, 0"

    1. Click the Edit | Editor Options | Key Assignment item.2. Expand the Bookmarks list by clicking the expand "+" button.

    3. Click Set Bookmark 0.

    4. Click the Edit Sequence button.

    5. In the Edit Key Pair step window press K. The key sequence displays in the window.

    6. Click Next.

    7. In the optional Step 2 window displays press 0.

    8. Your second key, 0, displays in the window.

    9. Click Finish.

    10. Press OK in the Editor Options window to save the setting.

    Note that keystrokes such as J or are ONE stroke keys.

    DO NOT CLICK the buttons ADD or DELETE unless the keys you just entered are in addition to the default keystrokes OR you want to remove the displayed keystrokes entirely. If you click DELETE while looking at a command, the hotkey for that command is removed.19

  • Toad for Oracle

    Right-click menusA right-click menu is specific to the window that you are in. Some items in the menu are shortcuts to commands or windows that can be found elsewhere, and some items are unique to the right-click menu and cannot be found anywhere else in Toad.

    To access a right-click menu

    Press the right mouse button (right-click)

    OR

    For the Procedure Editor, SQL Editor, and SQL Modeler windows you can also press F10.

    Window BarA window bar displays at the bottom of the main window screen to indicate what windows are open in Toad. Click a button on the bar to navigate to a window. The tooltips on the bar display the full window caption.

    Options for the window bar (Show connection string on buttons, Show window titles on buttons, and Highlight windows for current connection) appear under Options |Toolbars.

    If you want to undock the window bar from the bottom of the main window, check Options | Toolbars| Allow docking/hiding of read only toolbars.

    To turn off/on the window bar, right-click over it and uncheck/check Window Bar. If you are using a read-only toolbar configuration and you want the window bar to remain turned off, after unchecking Window Bar in the right-click menu, check Options| Toolbars | Allow docking/hiding of read only toolbars. 20

  • Basics

    Main ToolbarThe main toolbar buttons include buttons to open the major Toad windows such as the SQL Editor, Schema Browser, Procedure Editor, and SQL Modeler. Buttons also include Object Search, Run Script, Commit, Rollback, New connection, Configure/Execute external tools, Configure options, and more. You can place the mouse pointer over a button to display its title.

    Configure Toad Options

    You access the multi-tabbed Toad Options window via the Configure Toad Options button on the main toolbar or from the View | Options menu item. Many of the options are discussed in later chapters and in Toad Help.

    The Search button lets you search the options for specific text. This is useful, for example, if you can't remember which tab contains the option that you are trying to find. A table displays the list of options that contain the search text you type and the corresponding tab titles. Double-click the option, or click the option and press to go to that page.

    Save Toad Options

    The Save Toad Options button saves external files, which are basically your current Toad settings and values.

    This is useful if you are about to run a query that could crash or run for a long time. You might want to Save Toad Options before running such a query, just as a precaution. It saves all Toad options to files in your Toad and Toad\User Files folders including settings from the Toad Options dialog, Editor Options settings, Recall Previous SQL lists, Lists of MRU (Most Recently Used) files, Table Name alias list, etc.21

  • Toad for Oracle

    Offline Text Editor

    The Offline Text Editor button opens an Offline Text Editor window. So, you can edit scripts without being connected to an Oracle database.

    For example, by modifying the script files that define how the Toad Editor should highlight keywords, you could edit HTML files and have Toad highlight the HTML markup tags in various colors.

    The file language types supported are: PL/SQL, HTML, INI, JAVA , and TEXT. You can also open XML files (which will activate the XML Editor).

    The View |Options | Parser Scripts dialog is where you set up the file associations for file name extension.

    Configure the editor options by loading a file for a language into the offline editor and choosing Edit |Editor Options.

    XML Editor

    When you load an XML file into the offline text editor, a tree navigator for the XML displays on the left hand side. You can edit the XML in the text or in the tree. You can also open the XML Editor on CLOB datatypes that contain the XML page header. Save as works with XML data for some formats. Schema Browser files are stored as XML files.22

  • Basics

    Configure/Execute External Tools

    This opens the Tool Options window which lets you add programs that can be launched from Toad. The Add button opens a Tool Properties window that lets you add programs, select icons, pass in parameters to the program, create shortcuts (click in the Shortcut box and enter the new keystroke), and add macros. After you've added programs to the Tool Options window, they are available from the Configure/Execute External Tools dropdown list. The icon of the last program you execute from the dropdown replaces the Configure/Execute External Tools icon. You can then execute the last program by clicking its icon on the toolbar.

    An Auto add button searches the registry for a set of preinstalled programs. You select the programs that you want to add. It finds the program file, an icon, and establishes the working directory as the same directory where the executable resides.

    Project Manager

    The Project Manager lets you manage your common DB tasks from one central window.

    The Settings button opens the Configuration window where you can: specify the command Toad executes when you drag a file onto another file or onto a node, customize double-click operations, and customize the pop-up (right-click) menus. It also lets you configure the external associations and the DDL script inclusions.23

  • Toad for Oracle

    Project nodes let you store links to folders, connection links, and database objects.

    To Add a Project Node

    Right-click and select Add| Project.

    OR

    From the Add Item dropdown select Project.

    In order to add a folder to your project, it must exist on your hard drive.

    To Add a Folder

    Right-click and select Add | Folder.

    OR

    From the Add Item dropdown select Folder.

    When you add a folder, Project Manager maps the folder path. By default, double-clicking on the folder will open Windows Explorer to that folder. You can add items contained in the folder to the Project Manger window so that they can be accessed directly. FTP folders represent connections to a remote server and are located as sub-nodes to a project folder that you create. You can add a separate folder for each server directory that you want mapped.

    A Copy feature lets you have more than one project open at once with links to the same files, FTP connections, or schemas. The feature applies to second-level nodes: Schemas, Folders, and FTP Folders.24

  • Basics

    To Copy Nodes

    1. Select the node(s) you want to copy (multi-select via or )

    2. Right-click and select Copy from the menu. The Destination Projects window displays.

    3. Select the project(s) you want to copy to.

    4. Click Ok.

    Different project nodes can contain links to the same items. You can use different schemas or users in each project. Project Manager lets you access your connections, see if you are connected, and connect if the connection is not current. You can combine different Oracle connections and FTP connections into one project. You can configure Project Manger so that it will automatically run a Schema Compare when you drag one schema node onto another schema node.

    For more details about Project Manager refer to Toad Help.

    Object Palette

    The Object Palette is accessed from the View menu and docks to the main window. It replaces the Table Selector window that was in previous versions of Toad. It can list tables, views, or synonyms. A toggle button lets you display columns for the selected object. You can also select an object from the list and press F4 to perform a Describe. The Object Palette is required for the SQL Modeler and the ER Diagram.25

  • Toad for Oracle

    Customize (toolbars and menus)You access the Customize window via the right-click menu Customize command on either the main toolbar or main menu. This window lets you customize the main toolbar and the menu bar. You can also add new menus and new toolbars. You must have the Customize window open in order to customize toolbars or menus.

    If you want your menu lists to automatically hide items that you seldom use, you can turn this option on via the Customize window| Options tab by checking the Menus show recently used commands first option. If checked, the menu lists configure themselves in response to how often you use each menu command, moving the most used commands to the top of the list, and hiding commands that you seldom use. If you check Show full menus after a short delay, then after you select a menu and wait a few seconds, the remainder of the menu (the hidden menu items) displays. If the Show full menus after a short delay option is unchecked, you can still display the rest of the menu by clicking the down arrow at the bottom of the menu. The Reset my usage data button will reset the menu usage data.

    The Customize | Options tab also lets you display large icons, show/hide tooltips, show/hide shortcuts on tooltips, and select menu animations.

    If you want to make a lot of changes to the main toolbar, it might be easier to create your own custom toolbar via the Customize window| Toolbars tab. Click New, name your new toolbar and click OK. Then click-and-drag commands from the Commands tab to your new toolbar. You can remove a command from the toolbar by clicking and dragging it off the toolbar. Notice the commands are categorized by their associated menus. If an icon is associated with the command the button will display the icon by default. You can right-click on an icon to change it to text display, icon and text, edit the displayed text, and other options. When editing text, if you want to define a hotkey () type an ampersand (&) before the letter you want underlined. You change a hotkey by changing the position of the ampersand. You can click-and-drag New Menu from the Commands tab to add a menu to your new toolbar.

    While the Customize window is open, you can rearrange your customizable toolbar buttons and menus via click-and-drag. You can add a separator between groups of commands by clicking on a button and dragging it slightly left or right. The customizable toolbars (which includes the main toolbar) can be docked (via click-and-drag) to any side of the screen, or left as floating toolbars which will remain on top of all Toad windows. The Customize window |Toolbars tab lets you show/hide toolbars via check boxes next to each toolbar. Restore the default settings of a customizable toolbar through the Customize window by selecting the toolbar from the list and clicking the Reset button.26

  • Basics

    Toolbar Options

    View | Options|Toolbars lets you select or add a toolbar configuration. The preconfigured toolbars are read-only. Regardless of the configuration you choose, you will not receive items that you are not licensed to receive.

    User Default - keeps your customized toolbar or gives you the Toad Default toolbar (all toolbar items). This is the only choice that is customizable.

    Toad Default - all toolbar items that you are licensed to receive. Toad will have to be restarted.

    The Add button adds a new toolbar using an existing template that you can later customize. Name is the name you want displayed in the options screen and INI Filename is the filename for your new configuration.

    Allow docking and hiding of read-only toolbars

    Default - Unchecked

    Unchecked, Toad shows all toolbars in their default location at restart, and you cannot hide or move and dock read-only toolbars (such as the main menu toolbar). Checked, you can move and hide the read-only toolbars.

    Lock all toolbars

    Default - Unchecked

    If checked, this prevents the toolbars from being dragged from their current position and docked elsewhere. The toolbars can be locked in any position, docked or floating.

    Use vertical text when toolbars are vertical

    Default - Checked

    If checked, vertically docked toolbar text will display vertically. If unchecked, vertically docked toolbar text will display horizontally, possibly resulting in a wider toolbar to accommodate the horizontal orientation of the text.27

  • Toad for Oracle

    Window Bar

    Options let you Show connection string on buttons (Default-Unchecked)Show window title on buttons (Default-Checked)Highlight window buttons for current connection (Default-Checked).

    Visual Style dropdown

    You can select a new style from the dropdown list.

    Standard

    This is the original Toad style. Buttons are flat, but appear raised when the pointer is over them and depressed when selected.

    Enhanced

    This enhances the original Toad style with captions for docked windows and other visual enhancements.

    Flat

    This style gives a flat, two dimensional effect to the toolbars. Selected buttons are outlined with a hard border.

    Office 2003

    This style gives the menus and toolbars a blue-gradient Office 2003 style.

    XP

    This applies the XP style to the menus and toolbars.

    Auto-save current desktop on shutdown

    Default - Checked

    If checked, this saves your desktop options when you shutdown.

    If you are running on the Microsoft XP OS platform, you can use XP themes.28

  • Basics

    Menu Shortcut Customization windowYou can select Menu shortcuts from the right-click toolbar menu, to display the Menu shortcut customization window. The intuitive window lets you change, create, and reset shortcuts.

    Dockable windowsThe following windows are dockable: Object Palette, Code Snippets, Project Manager, Output.

    Dockable windows can be pinned or unpinned using the push-pin button. Pinning a window locks it in place where it is docked. Unpinning a window adds a toolbar to the side of Toad where the window is docked and turns on the auto-hide mode.

    Multiple windows can be docked on the left, right, or bottom of the main Toad window. Multiple docking configurations can be saved and restored with controls on the Desktop toolbar.29

  • Toad for Oracle30

  • SQL Editor

    Overview

    SQL Editor Toolbar

    Shortcut Keys

    Navigator Panel

    SQL Results Panel

    Code Snippets

    Explain Plan

    5 Options for the SQL Editor

    Executing Statements

    Configuring the Editor

    Editor Options

  • Toad for Oracle

    Right-click menu

    Script Debugger

    CodeXpert32

  • SQL Editor

    OverviewIf you have never used Toad, the SQL Edit window is a good starting point. The window contains a multi-tabbed text editing window to compose SQL statements or scripts, a navigator panel, and a results tab to display the results from SELECT SQL statements.

    The SQL Editor lets you type, edit, execute, and tune. The editing window is in the top panel and the results panel, the lower panel, displays fetched data. The results panel contains tabs for Data, Explain Plan, Auto Trace, DBMS Output, Script Output, Code Statistics, and Query Viewer. A horizontal splitter between the editor and results panel lets you size each component accordingly.

    The editing window support includes:

    Standard windows editing commands

    Multi-level undo

    Tabbed support for multiple scripts

    Support for files up to 4 gigabytes

    Double-click highlighting

    Popup menu for common editing functions

    Bookmarks for large files

    Ways to invoke the SQL Edit window

    Click the button in Toad's main toolbar.

    Select menu item Database| SQL Editor. Set the SQL Editor to StartUp on new connection in the View|

    Options|Windows dialog.

    Right-click on Connection toolbar and select New | SQL Editor.

    The SQL Edit window contains a main SQL Editor toolbar, an Edit toolbar (for common editing functions such as cut, copy, and paste), a Format Code toolbar, a Source Control toolbar, a SQL Recall toolbar, and a Current Schema toolbar, and a toolbar for the Script Debugger which is included with editions that have debugging functionality. 33

  • Toad for Oracle

    SQL Editor ToolbarThe SQL Editor toolbar buttons let you Execute the complete or highlighted statement, Execute the statement at the cursor, Cancel the currently running script or statement, Specify a file to save the current editor contents, Save to file, Execute explain plan, Tune, and Change session.

    Format Code ToolbarThe format code toolbar lets you access the code formatting functionality. It includes buttons that let you Format Code, Profile Code (display a code statistics summary), and Open CodeXpert (available in the SQL Editor) which opens by default as a docked window at the bottom of the screen.

    Source Control ToolbarThe Source Control toolbar is always available. It covers basic source control and should not be confused with Team Coding.

    SQL Recall ToolbarThe SQL Recall toolbar includes a named SQL dropdown that is a quick launch for named SQL. The SQL Recall window is discussed later in this chapter.

    Current Schema ToolbarThis toolbar lets you work with a schema other than the one where you are connected. It includes a dropdown box listing schemas on that connection. To use the Current Schema feature, you must have the ALTER SESSION privilege. This feature does not work with script execution or debugging commands.

    It will issue the ALTER SESSION SET current_schema command before and after every statement to prevent problems in other windows.34

  • SQL Editor

    Shortcut KeysA few keys to note

    F1

    You can press F1 to display the Help file.

    and will scroll through the SQL history.

    F4

    Describes an object (table, view, procedure, function, or package) in a popup window. You access an Object Describe window by placing the cursor on the name of a table, procedure, function, package or view in a Procedure Editor or SQL Editor and pressing F4. The Object Describe windows are similar to the Schema Browser windows for the corresponding object types.

    F10

    Displays the right-click menu for the section (Editor or results panel) that the cursor is in

    T

    Columns Dropdown - You put the cursor on the table name, and a popup window lists the columns in that table.

    Goes to the previously executed statement that you've run

    Goes to the most recently executed statement

    Goes to the beginning of the line

    Goes to the top of the editor. In the data grid, goes to the first row of the column the cursor is in

    Goes to the end of the line35

  • Toad for Oracle

    Goes to the last row of the column you are in

    If you need to examine rows at the end of a large recordset, refine your query with something like:

    Select * from tableWhere primary_key > value

    and re-execute it.

    You need to be careful when using . Toad shows queries quickly. Even in a table with a million rows the response to the initial query is almost immediate. This is because Toad only fetches and displays what it needs. But with Toad has to fetch EVERYTHING. This can be a long process. If a table has only a hundred rows, Toad can quickly fetch data when you press , but if a table has a million rows, the process could be time consuming.

    KEYSTROKE FUNCTION

    F1 Display SQL Editor section of Toad Help file

    F2 Toggle between full screen Editor and Editor/Results Panel display

    F2 Toggle full screen grid

    F3 Find next occurrence

    F3 Find previous occurrence

    F4 Describe Table, View, Procedure, Function, or Package in popup window

    F5 Execute as script (so does F11)

    F6 Toggle results grid

    F7 Clear all text

    F8 Recall previous SQL statement (invokes SQL Statement Recall window)

    F9 Execute statement

    F9 Verify statement without execution (parse)

    F9 Execute current statement at cursor36

    F10 Display right-click menu

  • SQL Editor

    F11 Execute as script (so does F5)

    F12 Pass the editor contents to the specified External Editor

    A Select all text

    C Copy

    D Show Procedure Arguments

    E Execute Explain Plan on the current statement

    F Find text (invokes Find Text window)

    G Goto line (invokes Goto Line window)

    L Convert text to lowercase

    M Make Code Statement

    N Recall Named SQL Statement (invokes SQL Statement Recall window)

    O Open a text file

    P Strip Code Statement

    R Find and Replace (invokes Find and Replace Text window)

    S Save File

    S Save File As

    T Display Columns dropdown

    U Convert text to uppercase

    V Paste

    X Cut

    Z Redo last Undo

    Display Previous Statement

    Display Next Statement (for use after )

    Navigates to previous tab in the editor

    Navigates to the next tab in the editor

    Navigates to the previous results panel tab

    KEYSTROKE FUNCTION37

  • Toad for Oracle

    In version 8.5 the SQL Editor has been merged with the Script Debugger screen. (The Script Debugger is available in editions with debugging functionality.) Prior to the merge, the Script Editor and Script Debugger had common keyboard shortcuts. For example F5 in the Script Editor would Execute as Script and in the Script Debugger would Set a Breakpoint. If you are upgrading to 8.5, the merge requires you to resolve the shortcut conflicts by right-clicking on the main Toad toolbar, choosing Menu Shortcuts, and adjusting conflicts to best suit your environment.

    Navigates to the next results panel tab

    In the data grids, go to the top of the recordset

    In the results grid, go to the first row of the column the cursor is in

    In the editors, go to the first row, first column of text.

    In the Data Grid, go to the end of the recordset

    In the editors, go to the last row, last column of text.

    See caution note in this section.

    Activate code completion template

    Cycle through the collection of MDI Child windows

    Execute current SQL statement at cursor

    . (period) Auto complete tablenames

    KEYSTROKE FUNCTION38

  • SQL Editor

    Using the SQL Editor

    Selecting a table to edit

    To edit a tables data, you can't simply type Select and the tablename. Nothing will happen. You have to include a rowid in your select statement.

    For example, if your tablename is DEPT and you type

    Select dept.rowid, dept.* from dept

    and press or F9 to execute, you can edit the data. You must have Show ROWID in Data Grids checked in View|Options | Data Grids - Data if you want ROWID to display in the results.

    Alternatively, you can type the Toad EDIT command to translate the command into a SELECT SQL statement with ROWID column.

    Edit dept

    and press or F9 to execute. Then you can edit the data.

    If you want to choose a table and can't remember the title or schema, open the Object Palette from the View menu. With the Object Palette, you can click on a table name and drag and drop that name to the SQL Edit window.

    Then type Edit before the name, and add a space.

    Example:

    edit dept

    Press F9.

    Your selected table displays in the Results Grid.

    Notice the status panel indicator at the bottom of the screen turns green. This indicates that the table data can be edited. When the indicator is red, the data cannot be edited, but it can still be selected and copied.39

  • Toad for Oracle

    Navigator PanelThe Navigator Panel displays an outline of the script in the active tab. Click on items listed to jump to that statement in the editor.

    The navigator identifies SQL Plus statements, comments, DML statements, and DDL statements.

    If you have the pointer over an item in the navigator, the entire statement displays as a tooltip. Statements must be separated by ";" in order to appear. It must be valid SQL Plus syntax.

    SQL Results PanelThe SQL Results Panel tabs include: Data, Explain Plan, Auto Trace, DBMS Output, Script Output, Code Statistics, Query Viewer, Script Debugger (for editions with debugging functionality), and CodeXpert.

    Data tab

    The SQL Results Data Grid lets you view output from select statements. The Grid lets you take the results of a query and perform a variety of functions and display options. It's more flexible than using SQL* Plus, because you can format the results visually or graphically.

    If you type and execute

    Select * from tablename

    in the SQL Editor, you can see all rows and columns of the given table in the results grid.

    Editable Data Grid

    The data grid that displays the results of the SQL queries is fully editable providing that the query returns an updateable resultset. Query statements MUST return the ROWID to be updateable.

    The Data Grid is discussed in detail in the Data Grid chapter of this manual.40

  • SQL Editor

    For example:

    select * from employee

    would not be updateable whereas:

    select employee.*, rowid from employee

    would be updateable.

    To overcome this obstacle, you can substitute EDIT Items which Toad will translate into the updateable version of the statement.

    For example:

    edit employee

    If the resultset is editable but remains read-only, make sure the View | Options | Data Grid - Data | Default to Read-Only option is not checked.

    A red or green box displays in the status panel indicating whether the recordset is editable (green) or not editable (red).

    Cursors

    You can view cursor data. When a query is run with a cursor, the cell with the cursor will display the word CURSOR. You'll need to right-click the cell and select Pop-up Editor or double-click the cell to see the cursor data. (In order for the memo editor double-click feature to work the View | Options | Data Grids - Data | Popup Memo Editor on double-click must be checked.) Data can only be displayed once per cell each time the query is run.41

  • Toad for Oracle

    Nested Table Data

    You can view and edit nested data. A cell in the results grid that contains the nested data will display the word DATASET. Double-click (if the option is enabled) or right-click and select Pop-up Editor to view/edit the nested table data.

    BFILE Data

    You can view BFILE data. A cell with BFILE data will display the word BFILE. A column will be added to the grid to show the BFILE directory. Double-click on the cell (if option is enabled) or right-click and select Pop-up Editor to display the data. If it is an image or text file Toad will launch the program that is associated with the extension. Toad does not provide editing capability for BFILE data. If you run the file in an associated program you might or might not be able to edit the file, depending on your rights.

    VARRAY Data

    You can view and edit VARRAY data. A cell with VARRAY data will display the word VARRAY. Right-click the cell and select Pop-up Editor or double-click the cell (if the option is enabled). The memo editor will display the first 100 entries in the VARRAY.

    Object Data

    You can view and edit object data. A cell containing object type data will display the data in parenthesis delimited by commas. To view/edit, double-click on the cell (if the double-click option is enabled) or right click on the cell and select Pop-up Editor.

    LONG and LONG RAW

    Toad does not display the data for LONG RAW columns in a SQL Edit Grid. LONG columns are columns that contain character data up to 2 gigabytes. You define them as "long" in your SQL script. LONG RAW columns contain binary data that cannot be displayed such as GIFs, Word docs, etc.

    LONG columns display the first several characters, and LONG RAW columns display as (BLOB).

    LONG is similar to CLOB, and LONG RAW is similar to BLOB. Toad can handle all four of these datatypes.42

  • SQL Editor

    You edit these columns by double-clicking on the column and editing from the popup windows that display. For LONG columns, the Memo Editor window is displayed. For LONG RAW columns the Blob Edit window is displayed. If the popup window does not display, go to the View | Options | Data Grids tab and make sure the Popup memo editor on double-click option is checked. It must be checked for the above functionality to work.

    The popup editor for LONG columns displays the column text. You can edit in the editor or load a file into the editor. The popup editor for LONG RAWS provides Load From File or Save to File functionality.

    LONG RAW columns display as (BLOB).

    Double-click a LONG or LONG RAW column to display the memo editor.

    Double-clicking on the LONGCOLUMN $define popups a memoeditor that contains the column text.43

  • Toad for Oracle

    Load From File lets you select a file from your hard drive and place it into the LONG RAW column in the Oracle database.

    Save To File lets you take the data from the LONG RAW column from the database and save it to a file on your hard drive.

    Note that the recordset has to be editable for the popup editors to edit the data. You can still use the popup editors to have a read-only view of the data.

    To Edit LONG and LONG RAW Columns

    LONG Columns

    The recordset has to be editable for the popup editors to edit the data.

    1. Create a table: "create table long_test (id number, long_col long)"

    2. Edit the table: "edit long_test"

    3. Insert a row: enter "1" for ID, then double-click on the long col cell

    4. Enter text.

    5. Click the right arrow. "select * from long_test" should view all records, including (at least the first few chars) the long cols.

    LONG RAW Columns

    1. Create a table: "create table long_raw_test (id number, long_raw_col long raw)"

    2. Edit the table: "edit long_raw_test"

    3. Insert a row: enter "1" for ID then double-click on the long raw col cell

    4. Pick a file to import.

    5. Click the right arrow Next Record button. "select * from long_raw_test" should view only id, long_raw_col should display (BLOB). 44

  • SQL Editor

    Single Record View

    The Single Record View button is present throughout Toad data windows and result grids. It is located on the top left of the table.

    Click the Single Record View button, and the Single Record View window displays for the record of the item you've selected. The arrow buttons in the window let you move up and down the columns. You can also insert records, delete records, and post edits.

    Here, the location for Department 30, Sales, was changed from Chicago to New York.45

  • Toad for Oracle

    Time Values

    When displaying dates with times, 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. Whether or not you use time, it's in there. It will also work accurately well past Y2K.

    Performing a 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.

    The time dropdown in the Toad Options | Data Grids - Data dialog (or right-click on the grid and select Grid Options) is for display purposes and does not affect the storage of time values.

    Explain Plan tab

    The Explain Plan tab displays the Explain Plan for the selected SQL statement including partition information for Oracle 8 and above. The interface has tabs for Operation, Object name, Rows, Bytes, Cost, TQ (Object Node), In/Out, PStart (Partition Start), and PStop (Partition Stop).

    Explain Plan can be printed from the SQL Editor window via the right-click menu item.

    Explain Plan is discussed in more detail later in this chapter.

    Viewing previous Explain Plans via View | Explain Plan will not work unless you first create the tables needed for storage and retrieval of Explain Plans which you can do automatically via the Server Side Object wizard (see the Getting Started Guide).46

  • SQL Editor

    Auto Trace tab

    Auto Trace displays the results of every statement issued while in auto trace mode. It helps with tuning. When you run a query you can find out some performance statistics related to that query. Auto Trace is not recommended if a query is going to return a lot of rows, because it will force a read of all data from the results of a query.

    DBMS Output tab

    When you execute a DBMS Output statement, the DBMS Output will automatically display in the DBMS Output tab of the results grid.

    Buttons let you Turn Output On/Off, Clear window, Set Output Buffer Size (invokes the Set DBMS Output Buffer window where you can set the size), Save to file, Print, and Delete Screen.

    Frequency of polling

    You can set the frequency of polling (2 seconds to 15 seconds).

    You can also open a new DBMS Output window by selecting the Open a new

    DBMS Output window button.

    DBMS Output is discussed in the Procedure Editor chapter.

    Script Output

    When you execute a script the results automatically display in this tab. When executing as script, you are not prompted to save changes because the script is not saved to a temp file. You can print from the Script Output tab via the right-click | Print menu item.

    The script editor allows multiple editor tabs (like in the Procedure Editor) each with its own results sets in the lower part of the editor. You can run multiple queries and get multiple grids back (one for each data set returned) using the new execute button.47

  • Toad for Oracle

    Query Viewer

    This tab displays currently running background queries, the database where they are running, their current execution time, and the SQL.

    Toads main Query Viewer window (under the View menu) shows all the user queries that Toad has run.

    The Error tab displays any error messages.48

  • SQL Editor

    Code SnippetsCode Snippets is a popup reference for Oracle SQL functions and expressions. To access the Code Snippets window click View | Code Snippets.

    In the Code Snippets window, an explanation of the item or function displays in the lower panel. Items can be dragged and dropped into your SQL script.

    The code snippets templates are in the Toad directory in Templates.xml. You cannot directly edit the templates. You would need to make modifications via the View | Options | Editors | Code Snippets page.

    Make Code Statement and Strip Code Statement

    The SQL Edit window contains two functions that simplify copying SQL statements from Toad to code development tools such as Delphi, VB, C++, Java, or Perl, and from those code development tools back to Toad. The functions are called Strip Code Statement P and Make code Statement M, available from the SQL Editor menu.

    Make Code Statement

    Adds the code development tool syntax to the SQL statement in the SQL Editor, and makes it ready to paste into the development tool code.

    When making code statements, rather than changing the code in the SQL Edit 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 copied to the clipboard."

    If you have multiple SQL statements in the SQL Editor, highlight the statement you want to make before executing the Make Code Statement function.

    Strip Code Statement

    Strips off the code development tool syntax from the SQL statement, and places it on the clipboard ready to paste.

    If you have multiple SQL statements in the SQL Editor, highlight the statement you want to strip before executing the Strip Code Statement function.49

  • Toad for Oracle

    Selecting the Code Development Tool

    You select the code development tool from the View | Options | SQL Editor | Make Code | Make Code Format dropdown menu. The Make Code Format dropdown menu 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). Delphi, VB, C++, Java, and Perl are supported. The default selection is VB. You can also create your own language templates.

    For information about Creating Make Code language templates, refer to Toad Help.

    The Make Code options page also includes two checkboxes.

    Select SQL statement based on cursor position

    Default - Unchecked

    When this option is selected, Toad will look at the location of the cursor and determine which SQL statement to select.

    Strip Code copies to clipboard

    Default -Unchecked

    When checked, if you choose to strip code, the code you strip is copied to the clipboard so that you can easily undo the operation. If you later strip additional statements, or perform other tasks that place data on the clipboard, the code is overwritten. Only the most recent action is saved.50

  • SQL Editor

    External Editor

    You can use an external editor to edit the SQL Editor contents. To set up, go to the Toad Options | Editors | External Editor Command Line. Enter the drive letter, path, and executable name of the external editor you want, e.g., c:\winnt\notepad.exe %S. While in the SQL Editor or Procedure Editor, press to invoke the external editor, which will start and load up the current Toad Editor contents. Use the external editor, save the contents, quit the external editor.

    You will be prompted to reload the contents of the file only if the View | Options | Procedure Editor | Reload files when activating Toad if the file time stamp is changed option is checked.51

  • Toad for Oracle

    Explain PlanExplain Plan (also called Execution Plan) displays steps that will occur in the selected SQL statement. This lets you visually see the steps. The purpose of Explain Plan is to determine the execution plan Oracle follows to execute a specified SQL statement. The Explain Plan function inserts a row describing each step of the execution plan into a specified plan table. If you are using cost-based optimization, Explain Plan also determines the cost of executing the statement based on the statistics that have been stored for the table.

    To execute Explain Plan on a SQL Statement

    In the SQL Editor, place the cursor on a SQL statement, go to SQL Window| Explain Plan Current SQL (OR E).

    If View| Options| Oracle| Save previous Explain Plan results is checked, then Explain Plans are stored in:

    Toad_PLAN_SQL and

    Toad_PLAN_TABLE

    Viewing previous Explain Plans via View | Explain Plan will not work unless you first create the tables needed for storage and retrieval of Explain Plans which you do automatically via the Server Side Object wizard (see the Getting Started Guide). E Explain Plans in the SQL Editor will work regardless, but it you have not created the tables needed you must set the View | Options | Oracle | Explain Plan Table name option to point your own plan table (Plan_Table). Make sure the View Options | Oracle | Save Previous Explain Plan Results option is checked.52

  • SQL Editor

    To run Explain Plan

    1. Load a SQL Script into the SQL Editor.

    2. Click on a SQL statement such as Select, Insert, Update, or Delete.

    3. Select SQL Editor| Explain Plan Current SQL menu item.4. Explain Plan results display in the results grid.

    Notice the Explain Plan results have expand and collapse buttons. They let you display the details that you need to see.

    If you attempt to activate an Explain Plan and you have not created the needed Toad temp tables (which you can do automatically via the Server Side Object wizard during the install or from the Tools menu (see the Getting Started Guide), you get an error message telling you the table or view does not exist.

    You can copy the Explain Plan hierarchy to the Windows clipboard or send it to the printer with a right-click over the Explain Plan output and selecting either the Copy to Clipboard or Print Results menu item

    View Explain Plan

    View Explain Plan displays a list of the previous Explain Plans that you've executed.

    To Access View Explain Plan

    1. Go to the View| Explain Plan menu item.2. Click the Explain Plan item.

    3. A list of previous Explain Plans displays.

    You must have the View | Options | Oracle | Explain Plan Table Name menu item entered, or you will not be able to view previous plans. The default entry is Toad_PLAN_TABLE.53

  • Toad for Oracle

    Explain Plan Treeview

    The Explain Plan treeview lists the contents of the Toad_PLAN_TABLE for the given statement id.

    Operation

    The concatenation of the OPERATION and OPTIONS columns of the plan table.

    Object Name

    The value of the OBJECT_NAME column of the plan table.

    Rows

    Number of rows accessed. This comes from the CARDINALITY column of the plan table. If appropriate, the number is converted to K (thousands), M (millions), or G (1000 millions, or billions).

    Bytes

    Number of bytes accessed. This is the value of the BYTES column of the plan table. If appropriate, the number is displayed in Kilobytes, Megabytes, or Gigabytes.

    Cost

    The value of the COST column of the plan table. If appropriate, the number is displayed in K (thousands), M (millions), or G (1000 millions, or billions). This column is not applicable to rule-based optimization.

    Object Node

    This column contains the contents of the OBJECT_NODE column used to keep track of the order in which operation's output is consumed for parallel queries. 54

  • SQL Editor

    In/Out

    The (abbreviated) value of the OTHER_TAG column in the plan table. It indicates how this step relates to the previous and subsequent steps with regard to parallel query execution.

    PStart

    This column represents the DISTRIBUTION and PARTITION_START columns of the plan table.

    ABBREVIATION MEANING

    (blank) Serial execution

    P->S Parallel to Serial

    P->P Parallel to Parallel

    PCWP Parallel combined with Parent

    S->P Parallel from Serial

    PCWC Parallel Combined with Child

    ABBREVIATION FOR PSTART MEANING

    ROWID Row Location

    KEY KEY

    KEY(I) KEY(INLIST)

    n Partition number for first partition in range

    n, m Partition and sub-partition number for first partition in range55

  • Toad for Oracle

    PStop

    This column represents the PARTITION_STOP column of the plan table.

    An operation's location in the treeview is determined by the values of LEVEL, ID, PARENT_ID and POSITION for the row containing it.

    Refer to Oracle documentation for more information on how to read and interpret an Explain Plan output.

    ABBREVIATION FOR PSTOP MEANING

    ROW L Row Location

    KEY KEY

    n Partition number for first partition in range

    n, m Partition and sub-partition

    number for last partition in range56

  • SQL Editor

    Recall and Add SQL

    You access the Add and Recall SQL dialogs items through the SQL Editor menu. The purpose of Add/Recall SQL is to create a list of previously executed SQL statements in order to recall them at a later date instead of having to retype them.

    You can check the Save Only Statements that are Valid check box in the View | Options | SQL Editor page. This check box item will only save those SQL statements that execute successfully. This prevents the list from containing misspelled column names, etc.

    SQL Recall Window

    The SQL Recall window is dockable and can be pinned or hidden.

    The SQL Recall window displays a list of the last X number of statements executed. The default number is 100, but you can change this in the options. The maximum is 999.

    Every statement executed in the SQL Editor is added to the statement recall list, unless you choose the option to only save valid ones. This list is organized with the most recent SQL at the top. You can select a statement from this list and run it, you can remove a statement from the list, and you can name your statements for easy recall. You can save a SQL statement as either a Personal SQL or Named SQL.

    All statements (to a maximum set in the SQL Options) are saved between sessions of Toad in the file Toad\User Files\savedsql.xml.

    The SQL Recall window displays the Name of SQL (if any), SQL statement, Connection information, and Date and time of last connection.

    There are also tabs to display All SQL and Single SQL which show more detail of a long SQL statement.

    You can search by clicking in the SQL Contains dropdown.

    The SQL Recall window is dockable within Toad.

    The SQL Recall Window toolbar is composed of two parts: the Main toolbar and the SQL Filter toolbar. You can hide or display each part.

    Main SQL Statement Recall Toolbar57

  • Toad for Oracle

    The Main SQL Statement Recall toolbar includes commands for working with the SQL statements that Toad has archived. You can save and copy SQL statements, remove selected SQL statements from the SQL list, Display connection information and the date last executed, edit via double-click in appropriate cell, and group by connection or SQL type.

    SQL Filter Toolbar

    The SQL Filter toolbar contains filtering options for your list of SQL statements. The SQL Contains dropdown lets you filter the list by a character string contained within the SQL. The Database dropdown lets you filter by Database. The Show dropdown lets you display History, Named, or Personal SQL statements.

    To recall a SQL command

    Press F8

    OR

    Select SQL Command Recall from the View menu

    Running a Recalled SQL Statement

    After a SQL statement is recalled and placed in the SQL Editor, press or F9. Toad will search backwards one line from the current cursor position to find a SQL statement to execute.

    Add to Personal SQLs

    Selecting this command from the SQL Editor menu adds the SQL statement that's in the SQL Editor to your Personal SQLs. You can later recall the statement by using the Recall Personal SQL command.

    Toad saves all statements in this list between sessions of Toad in a file named savedsql.xml in the Toad\User Files folder.

    To Add a SQL Statement to the Personal SQL List

    1. Select the statement by highlighting it in the editor.

    2. Click menu item SQL Editor| Add to Personal SQLs.58

  • SQL Editor

    Add to Named SQLs

    This window lets you add a SQL statement to a user's Named list.

    To Add a SQL Statement to the Named SQL List

    1. Select the statement by highlighting it in the editor.

    2. Click menu item SQL Editor| Add to Named SQLs.3. Type the name you want to assign.

    4. Click OK.

    Recall Named SQL

    Use this dialog to pick a SQL statement from your named list of SQLs, then copy it back to the SQL Edit window for execution. The Recall SQL window for Recall Named SQL lists the names on the left panel and highlights the corresponding SQL statement on the right panel.

    The SQL statements are stored in the Toad\User Files\savedsql.xml file.

    More about Recall

    You can view recalled SQL statements in groups or individually and move them into editors.

    To view all SQL statements

    1. From the View menu select SQL Command Recall.

    2. Click the All SQL tab.

    To view Personal and Named SQL

    1. From the View menu, select SQL Command Recall.

    2. Click the All SQL tab.

    3. Use the SQL Filtering toolbar to filter out everything but the Personal or Named SQL from the grid.

    To view individual SQL

    1. From the View menu select SQL Command Recall.

    2. Select one or more SQL statements.

    3. Click the Single SQL tab.

    In the single SQL tab, the operators F4, click, and right-click Describe are available.

    You can open SQL statements in the SQL Editor or drag-and-drop them into the 59

    Procedure Editor or Text Editor or by double-clicking them in the All SQL grid.

  • Toad for Oracle

    To drag-and-drop SQL statements

    1. Select one or more SQL statements from the SQL Recall window.

    2. Drag the selection to one of the editors and drop the selection in the editing window.

    If you want to open a SQL Statement in the SQL Editor, double-click on the desired SQL statement.

    You can scroll through the previous statements directly within a SQL Editor edit panel by pressing or .60

  • SQL Editor

    Options for the SQL EditorYou access the Toad Options menu via the Configure Toad Options button on the main toolbar or by selecting the View| Options menu item.

    The Options| SQL Editor contains numerous options on three pages.

    SQL Options page

    Only show one SQL Editor per database connection

    Default - Unchecked

    If checked, Toad will permit only one SQL Editor window to be opened per connection. This is similar to the one Schema Browser and one Procedure Editor per connection options.

    Scan statements for bound variables before execution

    Default - Checked

    If checked, Toad will scan SQL statements for bound variables and ask you for the values before execution. If unchecked Toad sends the query as is to Oracle.

    Always show statement execution time (overrides ROW:COL display)

    Default - Unchecked

    If checked, Toad will show the statement execution time in the status panel. If unchecked, Toad will show the statement execution time until you perform further editing, then the status panel will show the row and col location of the cursor in the editor.

    SQL Editor Options are in three dialogs: Options | SQL Editor, Options | Editors, and Edit | Editor Options.61

  • Toad for Oracle

    Automatically poll for DBMS Output if Output detected

    Default - Unchecked

    If checked, Toad scans statements run in the SQL Editor, looking for a DBMS_OUTPUT.PUT_LINE statement. If one is found, then Toad enables DBMS Output, polls once, and then disables DBMS Output again. The default is unchecked.

    Apply COMMIT and ROLLBACK to all tabs in the SQL Editor. This only applies when threaded queries are used.

    Default - Unchecked

    Prompt to save contents when closing editor

    Default - Checked

    If checked, Toad will prompt you to save any text you typed in the editor.

    If unchecked, you will still be prompted to save modified files loaded into the editor.

    Close query (grid) when clearing the SQL Editor

    Default - Checked

    If checked, this clears the Data grid whenever you clear the SQL Editor.

    Allow Clear All Text (buttons and F7 hotkey)

    Default - Checked

    If checked, you can press the F7 key to clear all text from the SQL Edit window without a confirmation dialog. If unchecked, F7 will not work, but you can still use the Edit | Clear All menu item.

    Max # of SQL statements to save textbox

    The default number is 100. The maximum is 999, but performance will be impacted.

    This box lets you enter a custom number of SQL statements to save to your Recall Previous SQL list. The list is saved to and retrieved from the savedsql.xml file. Only the most recently used SQL statements are saved.62

  • SQL Editor

    Save only statements that are valid

    Default - Checked

    If this option is checked, Toad will only save the SQL statements that ran successfully for recall via F8 SQL Statement Recall dialog.

    Write saved SQL statements to disk prior to statement Execution

    Default - Unchecked

    If checked, then Toad writes the list of saved SQL (everything in the SQL Recall window) to the disk just prior to SQL execution. This ensures that if the query crashes Toad during the execution, your SQL history is not lost. Note that it will not save the current option if the option to only save valid SQL is checked, because validation occurs after the query executes.

    Make Code page

    Make Code and Strip Code, including the Make Code option page are discussed earlier in the Make Code Statement and Strip Code Statement section of this chapter.

    Script Options page

    Login Scripts frame

    Glogin.sql (traditionally for group login settings) and login.sql (users personal login settings) are Oracle standards and used by SQL*Plus and other applications. Toad supports these for SQL Editor script executions. The boxes are read-only. Toad uses a SQL*Plus algorithm to find them.

    Glogin.sql is executed first and then login.sql is executed. So any settings in login.sql will take precedence over any settings that coexist in glogin.sql.

    glogin.sql

    glogin.sql is usually located in the ORACLE_HOME\sqlplus\admin folder.

    You can edit this file by clicking the Edit File button. The file will open in your selected text editor.63

  • Toad for Oracle

    login.sql

    Login.sql can be used to store initial settings for a script execution session.

    Toad finds login.sql by searching the initial working directory of Toad at startup. It is usually the installation folder unless you have changed the start location.

    If login.sql is not found there, Toad searches the SQLPATH for the active home. SQLPATH can contain many directories each separated by a semicolon.

    Execute login scripts

    Default - Never

    Radio buttons let you select Never, On SQL Editor startup, On reset settings.

    Restore SET option defaults before each script execution

    Default - Checked

    When checked, the SQL Plus SET options will be restored to their default values each time a script is executed in the SQL Editor. If unchecked, changes remain for all executions that follow.

    Script Output frame

    Limit output from SELECT queries to X rows, 0 will fetch all rows

    Entering a number in this box will limit your SELECT to that number of rows. Any results beyond that number of rows will be truncated. 0 shows all rows.

    The default is 0.

    Font button

    This button lets you select the font for your script output.

    Default - Courier64

  • SQL Editor

    Executing StatementsIf the SQL Edit window has a single statement that you wish to execute

    Press F9

    OR

    Click the Execute Statement button on the toolbar.

    If you only want to process a portion of the edit text

    Highlight that portion AND :

    Press F9

    OR

    Click the Execute Statement button.

    To execute a single statement among many statements (separated by at least one blank line)

    Click or place the caret/cursor within the statement you want to execute AND:

    Press F9 OR

    OR

    Click the Run Current Statement button on the toolbar.

    Toad supports query statements, DDL statements, blocks of procedure SQL, etc. Toad recognizes substitution variables in quotes as follows:

    If & is escaped, Toad will not prompt for a value.

    If & is the last character in a string, it is not considered a substitution variable.65

  • Toad for Oracle