Teradata SQL Assistant for Microsoft Windows User...

202
Teradata SQL Assistant for Microsoft Windows User Guide Release 14.01 B035-2430-032A March 2012

Transcript of Teradata SQL Assistant for Microsoft Windows User...

Page 1: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Teradata SQL Assistant for MicrosoftWindows

User Guide

Release 14.01B035-2430-032A

March 2012

Page 2: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

The product or products described in this book are licensed products of Teradata Corporation or its affiliates.

Teradata, Active Enterprise Intelligence, Applications Within, Aprimo, Aprimo Marketing Studio, Aster, BYNET, Claraview, DecisionCast, Gridscale, Managing the Business of Marketing, MyCommerce, Raising Intelligence, Smarter. Faster. Wins., SQL-MapReduce, Teradata Decision Experts, Teradata Labs Logo, Teradata Raising Intelligence Logo, Teradata Source Experts, WebAnalyst, and Xkoto are trademarks or registered trademarks of Teradata Corporation or its affiliates in the United States and other countries.

Adaptec and SCSISelect are trademarks or registered trademarks of Adaptec, Inc.

AMD Opteron and Opteron are trademarks of Advanced Micro Devices, Inc.

EMC, PowerPath, SRDF, and Symmetrix are registered trademarks of EMC Corporation.

GoldenGate is a trademark of Oracle.

Hewlett-Packard and HP are registered trademarks of Hewlett-Packard Company.

Intel, Pentium, and XEON are registered trademarks of Intel Corporation.

IBM, CICS, RACF, Tivoli, and z/OS are registered trademarks of International Business Machines Corporation.

Linux is a registered trademark of Linus Torvalds.

LSI is a registered trademark of LSI Corporation.

Microsoft, Active Directory, Windows, Windows NT, and Windows Server are registered trademarks of Microsoft Corporation in the United States and other countries.

NetVault is a trademark or registered trademark of Quest Software, Inc. in the United States and/or other countries.

Novell and SUSE are registered trademarks of Novell, Inc., in the United States and other countries.

Oracle, Java, and Solaris are registered trademarks of Oracle and/or its affiliates.

QLogic and SANbox are trademarks or registered trademarks of QLogic Corporation.

SAS and SAS/C are trademarks or registered trademarks of SAS Institute Inc.

SPARC is a registered trademark of SPARC International, Inc.

Symantec, NetBackup, and VERITAS are trademarks or registered trademarks of Symantec Corporation or its affiliates in the United States and other countries.

Unicode is a registered trademark of Unicode, Inc. in the United States and other countries.

UNIX is a registered trademark of The Open Group in the United States and other countries.

Other product and company names mentioned herein may be the trademarks of their respective owners.

THE INFORMATION CONTAINED IN THIS DOCUMENT IS PROVIDED ON AN “AS-IS” BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO THE ABOVE EXCLUSION MAY NOT APPLY TO YOU. IN NO EVENT WILL TERADATA CORPORATION BE LIABLE FOR ANY INDIRECT, DIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS OR LOST SAVINGS, EVEN IF EXPRESSLY ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

The information contained in this document may contain references or cross-references to features, functions, products, or services that are not announced or available in your country. Such references do not imply that Teradata Corporation intends to announce such features, functions, products, or services in your country. Please consult your local Teradata Corporation representative for those features, functions, products, or services available in your country.

Information contained in this document may contain technical inaccuracies or typographical errors. Information may be changed or updated without notice. Teradata Corporation may also make improvements or changes in the products or services described in this information at any time without notice.

To maintain the quality of our products and services, we would like your comments on the accuracy, clarity, organization, and value of this document. Please email: [email protected].

Any comments or materials (collectively referred to as “Feedback”) sent to Teradata Corporation will be deemed non-confidential. Teradata Corporation will have no obligation of any kind with respect to Feedback and will be free to use, reproduce, disclose, exhibit, display, transform, create derivative works of, and distribute the Feedback and derivative works thereof without limitation on a royalty-free basis. Further, Teradata Corporation will be free to use any ideas, concepts, know-how, or techniques contained in such Feedback for any purpose whatsoever, including developing, manufacturing, or marketing products or services incorporating Feedback.

Copyright © 2000-2012 by Teradata Corporation. All Rights Reserved.

Page 3: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Preface

Purpose

This book provides information about Teradata® SQL Assistant for Microsoft® Windows® which is a Teradata® Tools and Utilities product. Teradata Tools and Utilities is a group of products designed to work with the Teradata Database or other database.

Teradata SQL Assistant is a Windows-based information discovery tool designed to retrieve, manipulate, and store data from ODBC-compliant database servers.

Audience

This book is intended for use by:

• SQL proficient users who know how to formulate queries for processing on the Teradata Database or other ODBC-compliant systems

• Relational Database developers

Supported Releases

This book supports the following releases:

• Teradata Database 14.0

• Teradata Tools and Utilities 14.00

• Teradata SQL Assistant 14.01

Note: See “To display information about SQL Assistant” on page 38 to verify the Teradata SQL Assistant version number.

To locate detailed supported release information:

1 Go to http://www.info.teradata.com/.

2 Under Online Publications, click General Search.

3 Type 3119 in the Publication Product ID box.

4 Under Sort By, select Date.

5 Click Search.

6 Open the version of the Teradata Tools and Utilities ##.##.## Supported Platforms and Product Versions spreadsheet associated with this release.

Teradata SQL Assistant for Microsoft Windows User Guide 3

Page 4: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

PrefacePrerequisites

The spreadsheet includes supported Teradata Database versions, platforms, and product release numbers.

Prerequisites

The following prerequisite knowledge is required for this product:

• Teradata SQL, or the SQL of another ODBC compliant database

• Relational Database Management Systems

• Microsoft Windows operating system

• ODBC connectivity software

In addition, the following may be helpful to review prior to using Teradata SQL Assistant:

Changes to this Book

The following changes were made to this book in support of the current release. Changes are marked with change bars. For a complete list of changes to the product, see the Release Definition associated with this release.

This document... contains this information...

Windows Help file Online help, accessible from the Teradata SQL Assistant main window by clicking on the Toolbar.

4 Teradata SQL Assistant for Microsoft Windows User Guide

Page 5: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

PrefaceAdditional Information

Additional Information

Additional information that supports this product and Teradata Tools and Utilities is available at the web sites listed in the table that follows.

Table i: Changes to this Book

Date Description

March 2012

14.01

This release included the following changes:

• Added the ability to display Charts based on data in the Answerset. See “Charting Answerset data” on page 122.

• Added the ability to directly edit the data in a tableSee “Editing Table Data” on page 44.

• Added an optional pane to display and use Favorites and Statement Examples. See “Favorites and Examples Pane” on page 50.

• Added support for Transactions when connected in ANSI mode.See “Using Transactions” on page 73.

• Added additional information on the use of configuration files to set initial defaults after installation. See Appendix C: “Configuration Files.”

• Added new options for the handling of LOB columns. See “Setting Answerset Options” on page 117.

• Support optional column headers when opening an Answerset. See “Opening a Saved Answerset” on page 111.

• Provided additional information on the Status Bar.See “Using the Status Bar” on page 35.

Table ii: Additional Product Information

Type of Information Description Source

Release Overview

Late Information

Use the Release Definition for the following information:

• Overview of all of the products in the release

• Information received too late to be included in the manuals

• Operating systems and Teradata Database versions that are certified to work with each product

• Version numbers of each product and the documentation for each product

• Information about available training and the support center

1 Go to http://www.info.teradata.com/.

2 Under Online Publications, click General Search.

3 Type 2029 in the Publication Product ID box.

4 Click Search.

5 Select the appropriate Release Definition from the search results.

Teradata SQL Assistant for Microsoft Windows User Guide 5

Page 6: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

PrefaceAdditional Information

Additional product information

Use the Teradata Information Products web site to view or download specific manuals that supply related or additional information to this manual.

1 Go to http://www.info.teradata.com/.

2 Under the Online Publications subcategory, Browse by Category, click Data Warehousing.

3 Do one of the following:

• For a list of Teradata Tools and Utilities documents, click Teradata Tools and Utilities, then select an item under Releases or Products.

• Select a link to any of the data warehousing publications categories listed.

Specific books related to Teradata SQL Assistant for Microsoft Windows User Guide are as follows:

• ODBC Driver for Teradata User GuideB035-2509

• Teradata Query Scheduler User GuideB035-2497

• Teradata Visual Explain User GuideB035-2504

CD-ROM images Access a link to a downloadable CD-ROM image of all customer documentation for this release. Customers are authorized to create CD-ROMs for their use from this image.

1 Go to http://www.info.teradata.com/.

2 Under the Online Publications subcategory, Browse by Category, click Data Warehousing.

3 Click CD-ROM Images.

4 Follow the ordering instructions.

Ordering information for manuals

Use the Teradata Information Products web site to order printed versions of manuals.

1 Go to http://www.info.teradata.com/.

2 Under Print & CD Publications, click How to Order.

3 Follow the ordering instructions.

General information about Teradata

The Teradata home page provides links to numerous sources of information about Teradata. Links include:

• Executive reports, case studies of customer experiences with Teradata, and thought leadership

• Technical information, solutions, and expert advice

• Press releases, mentions and media resources

1 Go to Teradata.com.

2 Select a link.

Table ii: Additional Product Information (continued)

Type of Information Description Source

6 Teradata SQL Assistant for Microsoft Windows User Guide

Page 7: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Table of Contents

Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3

Purpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3

Audience . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3

Supported Releases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3

Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4

Changes to this Book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4

Additional Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5

Chapter 1: Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

What is Teradata SQL Assistant? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

How Teradata SQL Assistant Works . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

Teradata SQL Assistant Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

Defining a Data Source. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

Defining an ODBC Data Source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

Defining a .NET Data Provider for Teradata Data Source. . . . . . . . . . . . . . . . . . . . . . . . . 25

Defining a .NET Data Provider for Oracle Data Source. . . . . . . . . . . . . . . . . . . . . . . . . . . 28

Starting Teradata SQL Assistant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

Connecting to and Disconnecting from a Data Source. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

Connecting to an ODBC Data Source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

Connecting to .NET for Teradata. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

Connecting to .NET for Oracle. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

Connecting to Multiple Data Sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

Re-Connecting to a Data Source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

Displaying a Color Bar in the Query Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

Changing the Database Password. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

Main Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

Menu Bar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

Hiding Toolbars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

Using the Status Bar. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

Tabbing Windows. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

Cascading Windows. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

Teradata SQL Assistant for Microsoft Windows User Guide 7

Page 8: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Table of Contents

Tiling Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .37

Arranging Windows. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .37

Changing the text size in a child window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .37

Using Online Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .38

Using Shortcut Menus and Commands. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .38

Database Explorer Tree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .38

Viewing Object Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .39

Opening and Closing the Database Explorer Tree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .40

Navigating to the Database Explorer Tree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .40

Changing the Width of the Tree Area . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .40

Moving the Explorer Tree Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .40

Dragging Object Names to the Query Pane. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .41

Dragging Multiple Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .41

Using Quick Paste . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .41

Adding Double Quotes around Object Name. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .42

Adding Object Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .42

Displaying Object Definitions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .42

Displaying Data Source Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .43

Generating SQL for use with an Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .43

Editing Table Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .44

Working with the Edit Table Dialog Box. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .44

Adding Databases. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .46

Removing Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .46

Refreshing the Database Explorer Tree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .47

Displaying the Shortcut Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .47

Setting Database Tree Preferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .48

Favorites and Examples Pane. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .50

Opening and Closing the Favorites Pane. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .50

Navigating to the Favorites Pane . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .51

Changing the Width of the Favorites Pane . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .51

Moving the Favorites Pane Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .51

Listing All Tables or Views In a Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .52

Listing All Columns In a Table or View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .52

Setting General Program Preferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .53

Setting Default File Paths . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .54

Using Page Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .56

Using Print Preview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .57

Support for Unicode® and UTF-8. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .57

Displaying Unicode® Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .57

Exporting Unicode® Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .57

Importing Unicode® Data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .58

Support for the Visually Impaired. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .58

8 Teradata SQL Assistant for Microsoft Windows User Guide

Page 9: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Table of Contents

Text Size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58

Color scheme . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58

Audible support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58

Limitations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59

General Limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59

Teradata.NET Specific Limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59

Oracle.NET Specific Limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59

ODBC Specific Limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59

Chapter 2: The Query Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61

Introduction to the Query Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61

Using the Query Window. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62

Using SQL, DDL, and DML Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62

Displaying the Query Window Toolbar. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62

Allowing Multiple Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62

Splitting the Query Window into Two Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63

Selecting Text and Inserting Bookmarks Using the Query Window Margin . . . . . . . . . . 63

Creating Statements (Single and Multi). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63

Parameterized Queries. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64

Magnifying the Query Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64

Setting Query Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65

Setting Code Editor Options. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67

Entering and Executing Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69

Entering a Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69

Using Conditional Logic in a Query. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70

Using Code Completion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71

Customizing Code Completion Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72

Executing a Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73

Using Transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73

Running Multiple Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74

Executing Multiple Statements in Parallel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74

Submitting Part of a Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75

Aborting a Query in Progress . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75

Executing a Query Saved To a File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76

Automatically Minimizing the Teradata SQL Assistant Window . . . . . . . . . . . . . . . . . . . 76

Renaming a Query Tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76

Deleting a Query Tab. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76

Working With SQL Text in the Query Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77

Copying SQL from Previous History Record to the Query Window . . . . . . . . . . . . . . . . 77

Teradata SQL Assistant for Microsoft Windows User Guide 9

Page 10: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Table of Contents

Copying SQL from Next History Record to the Query Window . . . . . . . . . . . . . . . . . . . .78

Preventing Queries from Being Saved in the History Window . . . . . . . . . . . . . . . . . . . . . .78

Undoing or Redoing Query Window Changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .78

Setting Repeat Count . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .78

Recording and Executing Query Window Macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .79

Saving a Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .80

Performing a Quick Save. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .80

Adding a Query to Favorites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .80

Opening a Query from a File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .81

Copying a Query to Notepad . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .81

Printing a Query. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .82

Adding Comments to Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .82

Highlighting a block of Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .83

Showing Whitespace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .83

Converting Tabs to Spaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .83

Indenting Lines in a Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .83

Using the Right-to-Left Editor for Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .84

Deleting Blank Lines from a Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .84

Finding a Text String in the Query Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .84

Replacing a Text String in the Query Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .85

Displaying an Explain Plan of a Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .85

Displaying a Visual EXPLAIN Plan . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .86

Displaying a Textual EXPLAIN Plan . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .86

Query Builder Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .87

SQL Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .87

Procedure Builder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .88

<User Defined> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .88

Using Query Builder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .88

Supported Databases for Query Builder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .89

Creating Custom SQL Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .90

Scheduling Queries for Later Execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .91

Before Scheduling Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .91

Scheduling Queries for Later Execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .92

Formatting a Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .92

Indentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .92

Language Definition Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .93

Importing Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .94

Before You Begin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .94

Importing Data from a File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .95

Exiting from Import Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .95

Types of Import Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .95

Import Rules. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .97

10 Teradata SQL Assistant for Microsoft Windows User Guide

Page 11: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Table of Contents

Defining the Null Value for an Import Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98

Generating Multiple Reports From a Single Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98

Using the Query Window Shortcut Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99

Displaying the Shortcut Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99

Functions in the Query Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100

Chapter 3: The Answerset Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103

Introduction to the Answerset Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103

Using the Answerset Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104

Viewing Your Results. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105

Adjusting Row Height . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105

Adjusting Column Width . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105

Re-arranging Column Order . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105

Keeping Selected Columns From Scrolling Out of View . . . . . . . . . . . . . . . . . . . . . . . . . 106

Viewing Long Strings of Text Within Cells . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106

Closing Answerset Windows Before Submitting a New Query . . . . . . . . . . . . . . . . . . . . 106

Selecting All Answerset Rows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107

Merging Cells in the Answerset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107

Displaying the SQL That Generated an Answerset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107

Hiding Columns/Showing All Columns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108

Closing All Answersets. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108

Hiding Column Headers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108

Hiding Row Headers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108

Displaying Totals for Numeric Columns. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109

Displaying Aggregate Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109

Finding a Text String in the Results Grid. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109

Naming an Answerset Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111

Naming an Answerset Tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111

Deleting an Answerset Tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111

Opening a Saved Answerset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111

Saving an Answerset to a File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112

Saving as XML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113

Copying an Answerset to Notepad . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114

Printing an Answerset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114

Using Print Preview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114

Cancelling Print Jobs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115

Sorting an Answerset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115

Filtering the Answerset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116

Grouping the Answerset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116

Teradata SQL Assistant for Microsoft Windows User Guide 11

Page 12: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Table of Contents

Setting Answerset Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .117

Setting Data Format Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .119

Changing the Font for the Entire Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .122

Zooming the Answerset Window. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .122

Charting Answerset data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .122

Working with Charts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .124

Formatting an Answerset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .124

Formatting a Block of Cells . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .125

Formatting a Single Cell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .125

Formatting a Single Row or Column . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .125

Formatting Multiple Rows or Columns. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .125

Formatting the Entire Spreadsheet. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .126

Displaying Commas to Mark Thousand Separators. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .126

Displaying Numbers in Scientific Notation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .126

Displaying Decimal Places. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .126

Exporting a Resultset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .127

Exporting Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .127

Single-Clicking to Display the Export File. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .128

Saving Multiple Answersets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .128

Exporting to Access - Formats and Data Types. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .128

Setting Export/Import Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .129

Setting Export Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .130

Setting Import Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .131

Understanding Large Object Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .131

Using Answerset Shortcut Menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .132

Chapter 4: The History Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .135

Introduction to the History Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .135

The Columns of the History Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .136

Using the History Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .137

Opening the History Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .137

Closing the History Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .137

Viewing the Result Message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .137

Viewing DBS Error Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .138

Viewing the History Rows. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .138

Rearranging History Columns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .138

Filtering the History Rows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .138

Copying SQL from Previous History Record to the Query Window . . . . . . . . . . . . . . . .140

Copying SQL from Next History Record to the Query Window . . . . . . . . . . . . . . . . . . .140

12 Teradata SQL Assistant for Microsoft Windows User Guide

Page 13: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Table of Contents

Selecting All History Rows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141

Sorting the History Records . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141

Finding a Text String in the History Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142

Cleaning up the History table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143

Magnifying the History Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144

Setting History Window Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145

Editing History Records . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146

Displaying and Navigating the Edit History Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . 147

Editing a History Record . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147

Compacting History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147

Adding or Change a Note in a History Record . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147

Saving, Copying, and Printing History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148

Saving History Rows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148

Copying Rows to the Clipboard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150

Copying Rows to Notepad . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150

Printing the Contents of the History Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150

Cancelling Print Jobs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151

Storing History Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151

Changing the Location of History Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151

The History Window Shortcut Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152

Appendix A: Startup Parameters and Default Preferences. . . . . . . . . . . . . . . . . . 155

Startup Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155

Default Preferences (Options) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156

Miscellaneous and General Default Preference Settings. . . . . . . . . . . . . . . . . . . . . . . . . . 157

Query Default Preference Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159

Code Editor Tab Default Preference Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159

Data Format Tab Default Preference Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161

Answerset Tab Default Preference Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161

Export/Import Tab Default Preference Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162

History Tab Default Preferences and Descriptions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162

Database Tree Default Preferences and Descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163

File Paths Tab Default Preference Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163

Page Setup Default Preferences and Settings. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163

Teradata SQL Assistant for Microsoft Windows User Guide 13

Page 14: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Table of Contents

Appendix B: Menus, Toolbars and Shortcuts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .165

Using Toolbars and Buttons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .165

The Main Toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .165

The Answerset Toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .165

The Query Toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .166

Toolbar Button Descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .166

Customizing Menus and Toolbars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .172

Adding a Command to a Menu or Toolbar. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .172

Menu Commands Only. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .173

Removing a Command from a Menu or Toolbar. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .173

Moving a Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .174

Adding or Removing a Break Between Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .174

Changing the Name for a Command. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .174

Assigning or Changing a Keyboard Shortcut . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .174

Changing Menu Behavior . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .175

Showing Recently Used Commands First . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .175

Resetting the Default Menu Bar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .176

Hiding the Toolbars. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .176

Showing or Hiding Toolbar Screen Tips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .176

Adding, Removing, Renaming, or Resetting a Toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . .176

General Command Shortcut Keys. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .177

Query Specific Shortcut Keys. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .178

Window Control Shortcut Keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .181

Answer / History Specific Shortcut Keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .182

Appendix C: Configuration Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .183

UserOptions.config. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .183

Toolbars.config . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .184

DataSources.config . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .184

DockMgr.config . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .184

Vendors.config . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .184

14 Teradata SQL Assistant for Microsoft Windows User Guide

Page 15: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Table of Contents

Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187

Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193

Teradata SQL Assistant for Microsoft Windows User Guide 15

Page 16: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Table of Contents

16 Teradata SQL Assistant for Microsoft Windows User Guide

Page 17: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

List of Figures

Figure 1: The Default Main Toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165

Figure 2: The Default Answerset Toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166

Figure 3: The Default Query Toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166

Teradata SQL Assistant for Microsoft Windows User Guide 17

Page 18: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

List of Figures

18 Teradata SQL Assistant for Microsoft Windows User Guide

Page 19: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

List of Tables

Table 1: ODBC Data Source Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

Table 2: ODBC Driver Setup for Teradata Database Dialog Box: Field Descriptions . . . . . . 24

Table 3: Description of the Teradata.NET Connection Dialog Box. . . . . . . . . . . . . . . . . . . . . 27

Table 4: Description of the Oracle.NET Connection Dialog Box. . . . . . . . . . . . . . . . . . . . . . . 29

Table 5: Sub Folders Created When Objects Are Added. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

Table 6: Generate SQL Sub Menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43

Table 7: Explorer Tree Shortcut Menu Commands. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47

Table 8: Options Dialog Box, DB Tree Tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49

Table 9: Options Dialog Box, GeneralTab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54

Table 10: Description of the File Paths Options. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55

Table 11: Description of the Page Setup Dialog Box and Print Preview Window . . . . . . . . . 56

Table 12: The Query Tab in the Options Dialog Box. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65

Table 13: Code Editor Tab in the Options Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68

Table 14: Query Builder Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89

Table 15: Query Builder Icon Descriptions and Right-Click Options . . . . . . . . . . . . . . . . . . . 90

Table 16: The Query Window Shortcut Menu Commands and Descriptions . . . . . . . . . . . . 99

Table 17: Clipboard Support - Edit Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100

Table 18: Find Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110

Table 19: Answerset File Format Types. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112

Table 20: Answerset Tab in the Options Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118

Table 21: Data Format Tab in the Options Dialog Box. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120

Table 22: Chart Definition Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123

Table 23: Chart Menus and Shortcut Keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124

Table 24: How SQL Assistant Maps Teradata Data Types to Access Data Types . . . . . . . . . 128

Table 25: Import/Export Tab in the Options Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129

Table 26: Export Tab in the Options Dialog Box. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130

Table 27: Import Tab in the Options Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131

Table 28: The Answerset Window Shortcut Menu Commands and Descriptions . . . . . . . . 133

Table 29: The History Window Column Descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136

Table 30: Description of History Window Filter Options. . . . . . . . . . . . . . . . . . . . . . . . . . . . 139

Table 31: Find Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142

Table 32: Description of Cleanup History Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144

Teradata SQL Assistant for Microsoft Windows User Guide 19

Page 20: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

List of Tables

Table 33: History Tab in the Options Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .145

Table 34: History File Format Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .149

Table 35: The History Window Shortcut Menu Commands and Descriptions . . . . . . . . . . .153

Table 36: Startup Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .155

Table 37: Miscellaneous and General Default Preferences and Descriptions . . . . . . . . . . . . .157

Table 38: Query Default Preferences and Descriptions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .159

Table 39: Code Editor Tab Default Preferences and Descriptions . . . . . . . . . . . . . . . . . . . . . .159

Table 40: Data Format Tab Default Preferences and Descriptions . . . . . . . . . . . . . . . . . . . . .161

Table 41: Answerset Tab Default Preferences and Descriptions. . . . . . . . . . . . . . . . . . . . . . . .161

Table 42: Export/Import Tab Default Preferences and Descriptions. . . . . . . . . . . . . . . . . . . .162

Table 43: History Tab Default Preferences and Descriptions . . . . . . . . . . . . . . . . . . . . . . . . . .162

Table 44: Database Tree Default Preferences and Descriptions . . . . . . . . . . . . . . . . . . . . . . . .163

Table 45: File Paths Tab Default Preferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .163

Table 46: Page Setup Defaults and Descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .163

Table 47: Toolbar Button Descriptions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .166

Table 48: Adding, Deleting, Renaming and Resetting a Toolbar . . . . . . . . . . . . . . . . . . . . . . .176

Table 49: Shortcut Keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .177

Table 50: Query Specific Shortcut Keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .178

Table 51: Window Control Shortcut Keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .181

Table 52: Answer / History specific Shortcut Keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .182

Table 53: Properties Described by the Vendors.config File. . . . . . . . . . . . . . . . . . . . . . . . . . . .184

20 Teradata SQL Assistant for Microsoft Windows User Guide

Page 21: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

CHAPTER 1

Getting Started

The topics in this chapter provide the basic information required to get started using Teradata SQL Assistant:

• Introduction

• Defining a Data Source

• Starting Teradata SQL Assistant

• Connecting to and Disconnecting from a Data Source

• Main Window

• Database Explorer Tree

• Favorites and Examples Pane

• Listing All Tables or Views In a Database

• Listing All Columns In a Table or View

• Setting General Program Preferences

• Support for Unicode® and UTF-8

• Support for the Visually Impaired

• Limitations

Note: This document uses the term “database” as the term for “table qualifier” (the object that contains data tables). This term varies depending on the database vendor, and may be referred to as “owner”, “schema” or “catalog” in the vendor’s own documentation.

Introduction

This topic provides basic information about Teradata SQL Assistant and a brief overview of its features.

• What is Teradata SQL Assistant?

• How Teradata SQL Assistant Works

• Teradata SQL Assistant Features

What is Teradata SQL Assistant?Teradata SQL Assistant is an information discovery tool designed for Windows XP and Windows 7. Teradata SQL Assistant retrieves data from any ODBC-compliant database server. The data can then be manipulated and stored on a desktop PC.

Teradata SQL Assistant for Microsoft Windows User Guide 21

Page 22: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 1: Getting StartedDefining a Data Source

How Teradata SQL Assistant WorksTeradata SQL Assistant combines the data retrieved from ODBC databases with desktop applications such as Excel to create consolidated reports or to analyze the merged data. Teradata SQL Assistant records all SQL activity, complete with source identification, timings, row counts and notes. This is especially useful in data mining because the historical record can be used to build scripts from the SQL that produced positive results.

Teradata SQL Assistant FeaturesTeradata SQL Assistant has several key features:

• Create reports from Teradata or any Relational Database that provides an ODBC interface.

• Export data from the database to a file on a PC

• Import data from a PC file directly to the database

• Use an import file to create many similar reports (query results or Answersets). For example, display the DDL (SQL) that was used to create a list of tables. For more information, see “Generating Multiple Reports From a Single Query” on page 98.

• Send queries to any supported database or send the same query to many different databases

• Create a historical record of the submitted SQL with timings and status information such as success or failure

• Use SQL syntax examples to tailor statements

• Use the Database Explorer Tree to easily view database objects

• Use a procedure builder that provides a list of valid statements for building the logic of a stored procedure

• Limit data returned to prevent runaway queries

Defining a Data Source

When connecting to a database, select either ODBC, the .NET Data Provider for Teradata, or the .NET Data Provider for Oracle. Connection to any other database must be made through an ODBC connection. In order to use the ODBC connection, a vendor specific ODBC driver must be installed. In order to use a .NET Data Provider, that provider must be downloaded and installed.

See also the following sections:

• Defining an ODBC Data Source

• Defining a .NET Data Provider for Teradata Data Source

• Defining a .NET Data Provider for Oracle Data Source

Note: The .NET providers only appear in the dropdown list if they have been installed on the client system.

22 Teradata SQL Assistant for Microsoft Windows User Guide

Page 23: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 1: Getting StartedDefining a Data Source

Defining an ODBC Data SourceAn ODBC-based application like Teradata SQL Assistant accesses the data in a database through an ODBC data source.

After installing Teradata SQL Assistant on a workstation, start Teradata SQL Assistant. Then define a data source for each database.

The Microsoft ODBC Data Source Administrator maintains ODBC data sources and drivers and can be used to add, modify, or remove ODBC drivers and configure data sources. An About Box for each installed ODBC driver provides author, version number, module size, and release date.

Use the Microsoft ODBC Data Source Administrator program installed on the workstation to define a data source in one of two ways.

To define an ODBC data source

1 Do one of the following:

• From the Windows desktop, select Start > Control Panel > Administrative Tools > Data Sources (ODBC).

• From the Windows desktop, select Start > Programs > Teradata SQL Assistant 14.00 After Teradata SQL Assistant launches, select Tools > Define Data Source.

2 In the ODBC Data Source Administrator dialog box, decide what type of data source to create. Table 1 describes the data source types.

3 After selecting the DSN type, click Add.

For example: In the ODBC Data Source Administrator dialog box, click the System DSN tab to bring to the front. Click Add, then click OK.

4 In the Create New Data Source dialog box, select the appropriate driver and click Finish.

For example: Locate the Teradata driver under the column Name. Click to select the driver and click Finish.

Table 1: ODBC Data Source Types

Data Source Description Explanation

User DSN An ODBC user data source stores information about how to connect to the indicated data provider.

System DSN An ODBC system data source stores information about how to connect to the indicated data provider. A system data source is visible to all users on this machine, including NT services.

File DSN An ODBC file data source connects to a data provider. File DSNs can be shared by users who have the same drivers installed.

Note: File DSN is not recommended.

Teradata SQL Assistant for Microsoft Windows User Guide 23

Page 24: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 1: Getting StartedDefining a Data Source

5 A dialog box appears for the selected database. This dialog box requests information that defines the location of the database and the connection parameters to be used when establishing a connection. The parameters vary from one vendor database to another. Table 2 describes the basic parameters used to connect to a database.

Table 2: ODBC Driver Setup for Teradata Database Dialog Box: Field Descriptions

Select This Field... To...

Name Enter a name that identifies this data source.

For example, in some cases there is more than one Teradata server to connect to, or a user may have more than one logon depending on the function the user performs.

Description Enter a description. This is solely a comment field to describe the data source name used.

Name(s) or IP address(es) Enter the name(s) or IP address(es) of each LAN-connected node in the system, one per line. Entering only the first node name or IP address causes the client to communicate only with that node or IP address and can decrease system performance significantly.

Define any names entered here in either Domain Name Services (DNS) or the local hosts file. The hosts file is located in the system32\drivers\etc subdirectory of the directory in which Windows is installed.

Enter the name(s) or IP address(es) of the Teradata system.

Note: Never enter both a name and an IP address.

Do not resolve alias name to IP address

When this option is selected, setup routine does not attempt to resolve alias names entered into the "Name(s) and IP address(es)" box at setup time.

Instead it is resolved at connect time. When cleared, the setup routine automatically appends COPn (where n = 1, 2, 3, ..., 128) for each alias name entered.

This causes other IP addresses associated with this server to be located, until a break in the sequence is detected.

Use Integrated Security Select this option if logging on using integrated security measures.

Mechanism Leave this field blank to use the default mechanism.

Parameter The authentication parameter is a password required for the selected mechanism.

Username Enter a user name.

Password Enter a password to be used for the connection if using Teradata SQL Assistant in an unattended (batch) mode.

Entering a password here is not secure.

24 Teradata SQL Assistant for Microsoft Windows User Guide

Page 25: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 1: Getting StartedDefining a Data Source

Teradata SQL Assistant is ready to use.

For more information about using Microsoft ODBC Data Source Administrator, refer to the ODBC Data Source Administrator Help system.

Note: The SQL Assistant option Allow use of ODBC SQL Extensions in queries no longer exists. Clear the ODBC DSN option Disable Parsing to allow the use of ODBC SQL Extensions

in queries.

ODBC DriverBefore using Teradata SQL Assistant to access the data in the database, first install an ODBC driver on the PC. Each database requires a driver that is designed specifically for that database system. Obtain the appropriate driver from an database vendor or from a third-party supplier.

CompatibilityTeradata SQL Assistant is certified to run with any Level 2 compliant 32-bit ODBC driver. The product also works with Level 1 compliant drivers, but may not provide full functionality. Consult the ODBC driver documentation to determine the driver’s conformance level. Most commercially available ODBC drivers conform to Level 2.

Defining a .NET Data Provider for Teradata Data SourceUse the Connection Information dialog box to create, edit, and delete data sources for .Net Data Provider for Teradata. The dialog box is also used to connect to existing Teradata.Net data sources.

Data source definitions are saved to a file named DataSources.config.This file is located in \Users\<username>\AppData\Teradata\SQL Assistant on Windows 7 or \Documents and Settings\<username>\Application Data\Teradata\SQL Assistant otherwise.

Additionally, ‘system level’ data sources can be defined. These are stored in a file of the same name, located in \Users\All Users\AppData\Teradata\SQL Assistant on Windows 7 or \Documents and Settings\All Users\Application Data\Teradata\SQL Assistant otherwise.

When a System level data source is selected, a padlock icon appears to the right of the data source name. For a Windows user with Standard rights, many of the properties within such a

Default Database (optional) Enter the default database name.

If the Default Database is not entered, the Username is used as the default. All tables, views, and macros are assumed to be in this default database unless explicitly prefixed by a database name in the query.

Account String (optional) Enter one of the accounts that the DBA assigned to the Username when it was created.

Session Character Set Use the drop down menu to choose the character set. The default is ASCII.

Table 2: ODBC Driver Setup for Teradata Database Dialog Box: Field Descriptions (continued)

Select This Field... To...

Teradata SQL Assistant for Microsoft Windows User Guide 25

Page 26: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 1: Getting StartedDefining a Data Source

data source can not be changed. A user with Administrative rights may change any property. However, if he or she changes certain properties, a new user level data source is created. This user level data source appears instead of the system level data source going forward. If he or she later deletes that data source, the original System level data source is restored.

To define a Teradata .NET data source

1 Open Teradata SQL Assistant.

2 Select Teradata .NET from the provider drop down list, next to the Connect tool button.

3 Click the Connect icon or go to Tools > Connect.

4 Use the Connection Information dialog box to choose a .NET data source.

• Create a new data source by entering the name and server and other applicable information

• Delete an existing data source by clicking Delete.

• Use this dialog box to modify existing sources.

5 Use the Advanced tab to make additional changes to a data source. The figure below shows the .NET dialog box. Table 3 describes the options in the .NET dialog box.

26 Teradata SQL Assistant for Microsoft Windows User Guide

Page 27: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 1: Getting StartedDefining a Data Source

Table 3: Description of the Teradata.NET Connection Dialog Box

Dialog Box Item Description

Basic tab

Data Source Name Enter the name of the data source or use the drop down menu to choose an existing name.

Server Enter the name of the data source or the IP address.

Use Integrated Security Use your Windows credentials for this connection.

Mechanism Select a security mechanism and parameter. The default Mechanism is used if this is left blank.

Parameter Enter your security parameters if required by the selected Mechanism.

User Name Enter the appropriate user name information.

Password Enter the appropriate password information.

Default Database Enter the default database if applicable.

If the Default Database is not entered, the Username is used as the default. All tables, views, and macros are assumed to be in this default database unless explicitly prefixed by a database name in the query.

Account String Enter the default account string if applicable.

Advanced tab

Teradata SQL Assistant for Microsoft Windows User Guide 27

Page 28: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 1: Getting StartedDefining a Data Source

Defining a .NET Data Provider for Oracle Data Source Use the Connection Information dialog box to create, edit, and delete data sources for .NET for Oracle. The dialog box is also used to connect to existing Oracle .NET data sources.

To define an Oracle .NET data source

1 Open Teradata SQL Assistant.

2 Select Oracle.NET from the provider drop down list next to the Connect tool button.

Session Character Set Use the drop down menu to select a character set to be associated with the data source.

Session Mode Use Session Mode to select the type of session. Options include ANSI, DEFAULT, and TERADATA.

Response Buffer Size Enter a buffer size between 4096 and 1040000. The default is 65535.

Port Number Enter a port number. The default is 1025.

Connection Timeout Enter the length of time in seconds that SQL Assistant should wait for a connection to be established before determining that the system is unavailable. The default setting is 20 seconds.

Data Source DNS Entries

Optionally enter the number of IP Addresses defined for the Teradata system (1 to 999). The default setting is blank.

Use X views Select this box to force the driver to read the X (restricted) views instead of the regular views when fetching catalog data for the Database Tree.

Note: This option makes retrieving Database Tree information less efficient but may be required due to security restrictions for some users.

Use Data Encryption Select this box to use data encryption.

Verify Message Integrity Select this box to set the .NET Data Provider to perform integrity checks on all messages sent to and received from Teradata. The box is not selected by default.

Use Enhanced Schema Select this box to set the .NET Data Provider to return additional metadata information. This option also controls whether the StatementInfo parcel is returned by the database. The box is selected by default.

Show Color Bar Select this box to display a narrow bar of color across the top of any Query window that is connected to this data source.

Use the Color selection control to the right to select a color.

This same color is used to underline the Data Source name in the Database Explorer Tree when you are connected to this data source.

Table 3: Description of the Teradata.NET Connection Dialog Box (continued)

Dialog Box Item Description

28 Teradata SQL Assistant for Microsoft Windows User Guide

Page 29: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 1: Getting StartedDefining a Data Source

3 Click the Connect icon or select Tools > Connect.

4 Use the Connection Information dialog box to choose a .NET data source.

• Create a new data source by entering the name, server, and other applicable information.

• Delete an existing data source by clicking Delete.

• Use this dialog box to modify existing sources.

5 Use the Advanced tab to make additional changes to a data source. The figure below shows the .NET dialog box. Table 4 describes the options in the .NET dialog box.

Table 4: Description of the Oracle.NET Connection Dialog Box

Dialog Box Item Description

Basic tab

Data Source Name Enter the name of the data source or use the drop down menu to choose an existing name.

Server Enter the name of the data source or the IP address.

Use Integrated Security Use your Windows credentials for this connection.

User Name Enter the appropriate user name information.

Password Enter the appropriate password information.

Teradata SQL Assistant for Microsoft Windows User Guide 29

Page 30: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 1: Getting StartedStarting Teradata SQL Assistant

Starting Teradata SQL Assistant

After installing the .NET Data Provider for Teradata, Teradata SQL Assistant, and any required ODBC drivers or .Net data providers, start Teradata SQL Assistant.

To start Teradata SQL Assistant

✔ From the Windows desktop, select Start > Programs > Teradata Client 14.00 > Teradata SQL Assistant > Teradata SQL Assistant.

The Teradata SQL Assistant main window appears with a blank Query Window above and a History window below.

Connecting to and Disconnecting from a Data Source

Before connecting to an ODBC data source, a .NET data source, or both, the data sources should be defined. See “Defining an ODBC Data Source” on page 23 or “Defining a .NET Data Provider for Teradata Data Source” on page 25. More than one data source at a time can be connected if the option is selected on the Options dialog box under the General tab.

The following topics provide information about data source connections:

• Setting General Program Preferences

• Connecting to an ODBC Data Source

• Connecting to .NET for Teradata

Advanced tab

Proxy User Enter the Proxy user to connect through.

Proxy Password Enter the password for the Proxy user.

Connection Timeout Enter a time limit in seconds for SQL Assistant to establish a connection to an available system before timing out. The default setting is 20 seconds.

Show Color Bar Select this box to display a narrow bar of color across the top of any Query window that is connected to this data source.

Use the Color selection control, to the right, to select a color.

This same color is used to underline the Data Source name in the Database Explorer Tree when you are connected to this data source.

Table 4: Description of the Oracle.NET Connection Dialog Box (continued)

Dialog Box Item Description

30 Teradata SQL Assistant for Microsoft Windows User Guide

Page 31: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 1: Getting StartedConnecting to and Disconnecting from a Data Source

• Connecting to .NET for Oracle

• Connecting to Multiple Data Sources

• Re-Connecting to a Data Source

• Displaying a Color Bar in the Query Window

• Changing the Database Password

Connecting to an ODBC Data SourceAfter defining the ODBC data source, connect to it.

To connect to an ODBC data source

1 Use the provider drop down menu to select ODBC data source.

2 Do one of the following:

• Select Tools > Connect.

• On the Toolbar click .

The prompt asks for the name of the data source.

3 Select a data source and click OK.

4 In the Teradata Database Connect dialog box:

a Do one of the following:

• Select Use Integrated Security

• Enter the Mechanism and Parameter

• Enter the Userid and Password.

b Optionally, enter a Default Database or an Account String.

When the connection is complete, the Connect icon may be disabled and the Disconnect icon to its right is enabled. The connect icon is disabled only if connection to multiple data sources is not allowed.

For more information on the fields in this dialog box, refer to the ODBC Driver for Teradata User Guide.

When Connected to ODBCThe following are some characteristics that occur when connection is established with an ODBC source:

Teradata SQL Assistant for Microsoft Windows User Guide 31

Page 32: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 1: Getting StartedConnecting to and Disconnecting from a Data Source

• All columns are returned as character strings when Interval columns are selected. Because of this, you cannot select LOBs or Byte columns if your Select includes Interval columns.

• Only select CLOBs if you connect using the UTF-16 Session Character Set.

• Only type F User Defined Functions are listed under the Functions node of the Database tree.

• Time columns do not display fractional seconds or Time Zone information.

• Decimal columns with more than 28 digits may display incorrectly.

• If a macro (or execute parallel) returns zero rows from a Select statement, no rows are returned from any later Select statements in that macro or parallel query.

Connecting to .NET for TeradataUse this procedure to connect to a .NET for Teradata data source. For more information on defining .NET data sources, see “Defining a .NET Data Provider for Teradata Data Source” on page 25.

To connect to a .NET for Teradata data source

1 Use the Provider drop down menu to select Teradata.NET.

2 Do one of the following:

• Select Tools > Connect.

• On the Toolbar click .

The Teradata .NET Connection Information dialog box opens.

3 Select the data source and enter the applicable information.

When Connected to a Teradata .NET Data SourceThe following are some characteristics that occur when a connection is established with a Teradata .NET data source:

• Teradata.NET always uses ANSI date mode.All date literals must be entered in 'YYYY-MM-DD' format.

• Timestamp With Time Zone columns only sorts correctly if you specify a date format of 'YYYY-MM-DD'.

• A WITH (summary) clause in a Select statement causes the data return to fail.

32 Teradata SQL Assistant for Microsoft Windows User Guide

Page 33: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 1: Getting StartedConnecting to and Disconnecting from a Data Source

Connecting to .NET for OracleFor more information on defining .NET data sources, see “Defining a .NET Data Provider for Oracle Data Source” on page 28.

To connect to a .NET for Oracle data source

1 Use the Provider drop down menu to select Oracle.NET.

2 Do one of the following:

• Select Tools > Connect.

• On the Toolbar click .

The Oracle .NET Connection Information dialog box opens.

3 Select the data source and enter the applicable information.

When Connected to an Oracle .NET Data SourceThe following are some characteristics that occur when a connection is established with a Oracle .NET data source.

• Decimal columns with more than 28 digits may be displayed as <Error>.

• The correct case for Database/User names (generally Uppercase) must be used.This applies to the Connection dialog box, when adding Databases to the Explorer tree, or when enclosing object names within double quotes.

• Create Procedure statements must end with a semicolon.These statements create, but not compile, the procedure. The procedure must be compiled before it can be executed.

Connecting to Multiple Data SourcesUse the following procedure to connect to multiple data sources.

To connect to multiple data sources

1 Go to the Tools > Options > General tab.

2 Click Allow connections to multiple data sources (Query windows),

3 Follow the procedure for connecting to a data source.

Teradata SQL Assistant for Microsoft Windows User Guide 33

Page 34: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 1: Getting StartedConnecting to and Disconnecting from a Data Source

Each new data source appears in the Database Tree and opens a new query window with the data source name in its caption. To disconnect from a data source, click the Query window that is connected to that data source and click the disconnect icon.

Re-Connecting to a Data SourceUse the following procedure to reconnect to a data source to which the Query window was previously connected if the connection was dropped due to a network problem or the PC entering Hibernation.

To reconnect to a data source

✔ Do one of the following:

• Select Tools > Reconnect.

• On the Toolbar click .

Displaying a Color Bar in the Query WindowUse the following procedure to display a colored stripe across the top of a Query window. This provides visual feedback related to the data source to which the Query is connected.

To display a color bar in the Query window

1 When connecting to a Teradata.NET or Oracle.NET data source, click the Advanced tab.

2 Select the Show Color Bar check box.

3 Use the color selection dropdown control to select a color.

Changing the Database PasswordUse the following procedure to change the password in the database for Teradata, Oracle, MySQL and SQL Server databases. It may not be possible to change the password on all database systems, like Microsoft Access. Changing the password in the Database does not change a password that is stored in the ODBC data source definition. Storing a password in the ODBC data source is not secure and is not recommended.

To change the database password

1 Select Tools > Change Password.

2 In the Change Database Password dialog box, enter the current password.

3 Enter the new password.

Note: Do not use the semicolon (;) or the equal sign (=) when changing database passwords if any ODBC or .NET-based applications are being used.

4 Re-enter the new password to confirm it.

34 Teradata SQL Assistant for Microsoft Windows User Guide

Page 35: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 1: Getting StartedMain Window

Main Window

The Query Window is used to enter and execute a query. The results from queries are placed into one or more Answerset windows. See “Introduction to the Query Window” on page 61.

The Answerset window is a table that Teradata SQL Assistant uses to display the output of a query. See “Introduction to the Answerset Window” on page 103.

The History window is a table that displays past queries and related processing attributes. The past queries and processing attributes are stored locally in a Microsoft Access database. This provides flexibility to work with previous SQL statements in the future. See “Introduction to the History Window” on page 135.

In addition to the three main windows, the optional Database Explorer Tree and Favorites panes can be displayed at the left or right side of the main window. For more information on these features, see “Database Explorer Tree” on page 38 or “Favorites and Examples Pane” on page 50.

Menu BarThe Teradata SQL Assistant main window features a menu bar that contains menus that display a list of commands. The available commands apply to the active window.

To find information on main menu items, refer to the Index under the main menu name.

For information on customizing menus, see “Customizing Menus and Toolbars” on page 172.

Hiding ToolbarsThe Toolbars contain tool buttons used to perform the functions of the more commonly used menu commands.

For information on customizing toolbars, see “Customizing Menus and Toolbars” on page 172.

To hide the Toolbars

✔ Select View > Toolbars and then choose the Toolbar to hide.

Using the Status BarThe status bar appears across the bottom of the main window and displays status information such as:

• The status of an action or descriptive information about the Menu or Tool button that the mouse is currently hovering over

For example, after executing a query, the status bar displays a success or failure message for that query.

Teradata SQL Assistant for Microsoft Windows User Guide 35

Page 36: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 1: Getting StartedMain Window

Note: If a message is too long to fit on the status bar, click on it to display the full message in a message box.

• The sum, count, average and standard deviation for the highlighted block of cells in the Answerset window

To display this information, see “Displaying Aggregate Values” on page 109.

• The name of the Data Source from which the data was retrieved when an Answer set window is active, or the name of the Data Source to which the Query window is connected if a Query window is active

• The line number of the cursor position in the Query window

The line number is useful for locating syntax errors in stored procedures.

• The length of the selected text if any text is selected in the Query window

• The current zoom factor

• The current time

By default this displays only the hour and minutes. Click on it to display seconds also. Click on it again to return to the default display.

To hide the Status Bar

✔ Select View > Status Bar.

Tabbing WindowsQuery, History, and Answerset windows can be displayed as tabbed windows instead of the usual Tiled, Cascaded, or Maximized options. When tabbed, the windows can be split into two tab groups to allow you to easily compare the contents of each window.

To tab windows

✔ Under Window on the Toolbar, select Tabbed. The open windows arrange in tabs.

After the window is tabbed, a second tab group can be opened either by right-clicking on a tab and using the menu, or by dragging the tab to any edge of the window. (Dragging to a side opens side by side tab groups, while dragging to the top/bottom opens one tab group above the other.)

A tabbed window can also be dragged to a new location within its own tab group, or to another tab group.

36 Teradata SQL Assistant for Microsoft Windows User Guide

Page 37: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 1: Getting StartedMain Window

Cascading WindowsTo display all the open windows, use the cascade function. The following procedure explains how.

To cascade windows

✔ Do one of the following:

• On the Toolbar click .

• Select Window > Cascade.

• Press Shift+F5

Tiling WindowsUse the tiling function to display all of the open windows.

To tile windows

✔ Do one of the following:

• On the Toolbar click .

• Select Window > Tile Horizontal or Tile Vertical.

• Press Shift+F4 or Shift+F6

Arranging WindowsUse the following procedure to arrange all minimized windows in a row across the bottom of the Teradata SQL Assistant window.

To arrange icons

✔ Select Window > Arrange Icons.

Changing the text size in a child windowUse the following procedure to change the text size used in a child window.

To increase/decrease the text size in a child window

1 Make sure the window is active.

2 Hold the Ctrl key and spin the mouse wheel, or press the + or - keys. The display zooms in or out.

3 To restore the zoom level to its original size (100%) press Ctrl+0

Teradata SQL Assistant for Microsoft Windows User Guide 37

Page 38: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 1: Getting StartedDatabase Explorer Tree

Using Online HelpThe following explains how to use the help menu items.

To display help menu items

✔ Do one of the following:

• Select Help > Help Topics.

• On the Toolbar click .

To display context-sensitive help

✔ Press F1 anywhere in the program.

To display information about SQL Assistant

The About screen provides useful information about SQL Assistant and the current session, including the software version of SQL Assistant, the type and version of the connected server, and information about the ODBC driver.

✔ Select Help > About SQL Assistant.

Using Shortcut Menus and CommandsTo find information on menu items, refer to the Index under the menu name. Information on the shortcut menus for each window may be found as follows:

• Using the Query Window Shortcut Menu

• Using Answerset Shortcut Menus

• The History Window Shortcut Menu

• Displaying the Shortcut Menu

Customizing Shortcut MenusShortcut menus can be customized. For more information, see “Customizing Menus and Toolbars” on page 172.

Database Explorer Tree

The Database Explorer Tree can be displayed at the left or right side of the main Teradata SQL Assistant window. This pane displays each of the Data Sources to which you are connected. Opening a data source displays an alphabetical list of databases on that Data Source. Double-click a database name to expand the tree display for that database.

Use the Database Explorer Tree to reduce the time required to build a query, help reduce errors in object names, or to generate statements for a table.

38 Teradata SQL Assistant for Microsoft Windows User Guide

Page 39: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 1: Getting StartedDatabase Explorer Tree

Initially, the following databases load into the Database Explorer Tree:

• The user's default database

• The User ID that was used to connect to the database (if applicable)

• The catalog database defined in the Vendors.config file for the database vendor, for example "DBC" when connecting to a Teradata data source

• Any databases that you have previously requested to be loaded for this data source

Below each database name the following folders display:

• Tables

• Views

• System Tables (not for Teradata)

• Macros (for Teradata data sources only)

• Functions

• Procedures

Viewing Object TypesThe Database Explorer Tree shows the objects in the various databases shown. The following sections explain how the Explorer Tree works.

To expand the Explorer Tree to show all the objects

✔ Do one of the following:

• Double-click the database name or folder.

• Click the plus sign (+) next to the database name or folder.

• Highlight the database name or folder, and press Enter or the right arrow key.

• Right-click on the database name or folder, then select Expand/Collapse on the shortcut menu.

Note: The following notes apply to the Database Tree:

• Expanding the Tables, Views or System Tables folder loads all these object types.

• Expanding the Macros, Functions or Procedures folder loads all these object types. If no objects exist for a given object type, that folder is automatically removed.

• When an index node is expanded for a Table, the approximate index cardinality (number of unique values) appears after the column name(s). (Applies to ODBC connections only.)

• When expanding the Tables node of a database any Global Temp Tables in that database are listed in blue.

To collapse the Explorer Tree to hide all of the objects

✔ Do one of the following:

• Double-click the database name or folder.

Teradata SQL Assistant for Microsoft Windows User Guide 39

Page 40: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 1: Getting StartedDatabase Explorer Tree

• Click the minus sign (-) next to the database name or folder.

• Highlight the database name or folder, and press Enter or the left arrow key.

• Right-click on the database name or folder, then select Expand/Collapse on the shortcut menu.

Opening and Closing the Database Explorer Tree

To open or close the Database Explorer Tree

✔ Do one of the following:

• On the Toolbar click .

• Select View > Explorer Tree.

The check mark displays the status by toggling on or off.

Navigating to the Database Explorer TreeUse the following procedure to move focus to the Database Explorer Tree.

To navigate to the Database Explorer Tree

✔ Do one of the following:

• Select View > Go To Explorer.

• Press Ctrl+G.

Changing the Width of the Tree Area

To change the width of the Explorer Tree area

✔ Click on the right edge of the display and drag it to a new position.

Moving the Explorer Tree WindowThe Database Explorer Tree window operates as a separate window that can be moved around and docked to the left or right side of the parent window or can float independently.

The Database Explorer Tree also has an auto-hide feature that causes it to collapse to a bar when the mouse moves away from the window.

To move the Database Explorer Tree

✔ To move the Database Explorer Tree, do the following:

• Click the caption bar of the Database Explorer window and drag it to a desired location. When the cursor is close to the left or right edge of the main window, it

40 Teradata SQL Assistant for Microsoft Windows User Guide

Page 41: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 1: Getting StartedDatabase Explorer Tree

displays a bold outline indicating that it is ready to dock to that side. Otherwise it floats when the mouse button is released.

• If the Database Tree and Favorites pane appear as tabs and you only want to move one of them, click on the tab itself and drag that to the desired location.

✔ To auto-hide the Database Explorer window, do one of the following:

• Click the push pin on the caption bar to activate auto-hide or “unpin” the Explorer Tree.

• When you move the mouse away from the Explorer Tree, the window collapses to a bar at the side of the main window. When you move the mouse over the Explorer Tree tab on the bar, the Database Explorer Tree window reopens .

• Click the push pin again to turn off auto-hide.

Dragging Object Names to the Query PaneClick and drag the object from the Explorer Tree to the Query pane. The name of the object appears in the Query Window.

Use the Ctrl key to add a comma after the object name when it is dragged to the Query pane.

To qualify object names with their parent name when dragging an object to the Query Window, first select the option Qualify names when dragged or pasted from the Database Tree, on the DB Tree tab of the Options dialog box.

Dragging Multiple ObjectsUse the Shift and Ctrl keys to select more than one object from the Database Explorer Tree that can be dragged to the Query window.

Use the Ctrl key to select additional objects.

Use the Shift key to select a range of objects.

Using Quick PasteQuick paste allows you to easily move objects from the Explorer Tree to the query window.

To use quick paste

✔ Perform a quick paste in one of the following ways:

• Double-click a column name in the Database Explorer Tree to quickly move it to the Query window.

• Select the object, then right-click and select Quick Paste from the menu. The object is immediately pasted into the Query window.

Teradata SQL Assistant for Microsoft Windows User Guide 41

Page 42: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 1: Getting StartedDatabase Explorer Tree

Adding Double Quotes around Object NameRequest that double quotes be automatically added around any object name that is dragged, or quick pasted, from the Database Tree by checking the option Enclose names in quotes when dragged or pasted from the Database Tree on the DB Tree tab of the Options dialog box.

Adding Object TypesA newly creatd object does not appear in the Database Explorer Tree until the parent folder opens. If the parent folder is already open or has been opened during the current session, the new object does not appear until after the Refresh Database command is used, or disconnect and reconnect to the database. The same holds true when deleting an object. Table 5 shows the subfolders that are created when objects are added. For more information, see “Refreshing the Database Explorer Tree” on page 47.

Displaying Object DefinitionsUse the following procedures to display the text (the DDL or data definition language) used to create a table, view, macro or stored procedure in the Database Explorer Tree. The resulting text appears in the Answerset or Query window depending on which procedure you use.

To display the text used to create an object in the Answerset window

✔ Right-click on the object, then select Show Definition.

Abort the data retrieval process at any time by clicking the Abort icon on the toolbar. The results appear in the Answerset window.

Definitions are available as follows:

• Tables - Full definition for Teradata only. Column information only for other vendors.

• Views, Macros, Procedures and Functions - Teradata, Oracle, SQL Server and Sybase

Note: The definition for a Function or Procedure may not always be available.

To display the text used to create an object in the Query window

✔ Right-click on the object, then select Generate SQL>Create.

Table 5: Sub Folders Created When Objects Are Added

When adding a... the following subfolder(s) are added...

Table Columns and Indexes

View Columns

Macro

Function

Procedure

Parameters

42 Teradata SQL Assistant for Microsoft Windows User Guide

Page 43: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 1: Getting StartedDatabase Explorer Tree

Abort the data retrieval process at any time by clicking the Abort icon on the toolbar. The results appear in the Query window.

Definitions are available as follows:

• Tables - Full definition for Teradata only. Column information only for other vendors.

• Views, Macros, Procedures and Functions - Teradata, Oracle, SQL Server and Sybase

Note: The definition for a Function or Procedure may not always be available.

Displaying Data Source InformationTo display data source information, use the mouse to hover over the data source node. Hovering displays the User Name and Default Database for that data source.

Generating SQL for use with an ObjectUse the following procedure to insert a statement template for the selected Table or View into the Query Window rather than dragging individual column names to build a statement that references many columns of a table.

If the Ctrl key is pressed when the menu is clicked, the SQL is inserted into the current Query at the cursor position. If the Ctrl key is not pressed, the SQL will be displayed in a new Query tab if the current query has been changed since it was last saved or executed, or the SQL will replace the current query if it has not been changed since it was last saved or executed.

To insert SQL for the selected table or view into the Query Window

1 Right-click on the object and select Generate SQL.

2 Click on one of the sub menus to insert the SQL. Table 6 provides examples of the submenus.

Table 6: Generate SQL Sub Menus

Menu Item Inserted SQL Example

Select Select col1, col2, col3 From MyTable

Insert (Values) Insert Into MyTable (col1, col2, col3)

Values (col1 [Integer], col2 [Char(5)], col3 [BLOB])

Insert (Import) Insert Into MyTable (col1, col2, col3)

Values (?, ?, ?B)

Create Inserts the DDL of the object

Teradata SQL Assistant for Microsoft Windows User Guide 43

Page 44: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 1: Getting StartedDatabase Explorer Tree

Editing Table DataThe following steps explain how to directly edit the data in a table or simple view.

Note: This functionality is not available when connected via ODBC.

To edit table data

1 Right-click on a Table or View name in the Database Explorer Tree and then select Edit Table. The Edit Table Filter dialog box appears.

2 In the Edit Table Filter dialog box, deselect any columns that you do not want in the output.

Note: The selected columns must include a unique column or key if you plan to update the data. LOB columns do not appear in the list. Columns defined as Not Null are disabled because they are always selected.

3 [Optional] Enter a Where clause to limit the rows returned and an Order by clause to specify the initial sort order of the displayed rows.

4 Press OK to display the matching data in the Edit Table dialog box.

Working with the Edit Table Dialog BoxWhen the Edit Table dialog box first appears it is in read-only mode. To enter edit mode, do one of the following:

• Double-click the cell to edit.

• Navigate to the row to edit and press Enter to enter edit mode for the first column in the row. Press Tab to move to other cells in the row.

44 Teradata SQL Assistant for Microsoft Windows User Guide

Page 45: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 1: Getting StartedDatabase Explorer Tree

After editing a cell you may do the following:

Note: In many cases you cannot exit edit mode if you enter a value that is invalid for the underlying data type. If this occurs, either correct the value or press Esc to revert to the original value.

After a value has been changed, the Update and Revert buttons are enabled and the background color of the row changes. The default color is gold, but this can be changed using the Code Editor tab of the Options dialog box.

After making all changes, press Update to apply them to the underlying table. If all changes are successful the background color of the updated rows revert to normal. If any row(s) fail to update due to table constraints and so forth, an error message appears and those rows retain their changed background. Click on each row to display a message indicating the error that occured.

To edit large text values

If you try to edit a character value whose column is defined as larger than 80 characters, or whose value contains a carriage return, the Edit Text Cell dialog box appears.

1 Double-click or press Enter to enter Edit mode.The Edit Text Cell dialog box appears with the text shown in a multi-line text box.

2 Make your changes to the text, then press Save to accept the change or press Cancel to discard the change.

To insert new rows into the table

1 Double-click the ‘Insert’ row to enter Edit mode.The Insert row is immediately below the column titles, indicated by an asterix in the left margin and a pale cream (default) background.

2 Enter a value for each non-Null column.

As soon as you exit edit mode, the new row moves down to the main grid area and the top row becomes available for adding another row. Newly added rows also display the changed background color until the Update button has been pressed.

Click or press To

Enter To accept the new value and exit Edit mode

Tab To accept the new value and edit the next cell

Esc Revert to the old value and exit Edit mode

Mouse button To accept the new value and exit Edit mode

Teradata SQL Assistant for Microsoft Windows User Guide 45

Page 46: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 1: Getting StartedDatabase Explorer Tree

To delete rows from the table

1 Select the rows to be deleted.

2 Right click and press Delete Rows.

3 Click Yes when asked for delete confirmation.

The deleted rows immediately disappear from the grid but are not removed from the underlying table until Update is pressed.

To discard changes without applying them to the table

✔ Press the Revert button

The data is reloaded from the underlying table and all rows revert to the default background color.

Adding DatabasesThe following steps explain how to add additional databases to the Database Explorer Tree.

To add additional databases

1 Do one of the following:

• With the Database Explorer Tree active, press Insert.

• Right-click anywhere in the Database Explorer Tree, then select Add Database.

2 Type the database name to be added.

3 Clear the check box to load the database only for the current session. By default, the check box is selected so the database appears in the Database Explorer Tree in future sessions.

Removing DatabasesTo remove databases from the Database Explorer Tree, use the following procedure. If a database is removed by mistake, it can be added again. See “Adding Databases” on page 46.

To remove a database

✔ Do one of the following:

• Click on the database name and press Delete.

• From the Database Explorer Tree, right-click on the database name and click Remove Database.

Note: The default database can not be removed from the Database Explorer Tree.

46 Teradata SQL Assistant for Microsoft Windows User Guide

Page 47: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 1: Getting StartedDatabase Explorer Tree

Refreshing the Database Explorer TreeThe following steps explain how to refresh the objects shown below a database in the Database Explorer Tree.

To refresh the objects shown below a database

1 From the Database Explorer Tree, right-click the database.

2 Select Refresh Database.

Note: Only object types previously expanded are refreshed.

Displaying the Shortcut MenuThere are several ways to bring up additional menu options. Table 7 describes all of the commands.

To display commands for the Database Explorer Tree Window

✔ Do one of the following:

• Right-click an object and select a menu item.

• Press Shift+F10.

• Press Context Menu on the keyboard.

Table 7: Explorer Tree Shortcut Menu Commands

Command Description

Quick Paste Pastes the current object name into the Query Window. The name is inserted at the current insertion point. To insert the name at a different point, drag and drop it within the query text.

Show Definition Displays the text used to create an object in the Database Explorer Tree. The DDL (data definition language) of a table, view, macro or stored procedure appears in the Answerset Window. Right-click the object to show the definition, then choose this command.

Expand/Collapse

Expands or collapses the display for the selected object. If the selected object has not been previously opened, the child data (for example, the list of tables) is fetched from the database. If the selected object has no children, it is removed from the tree.

Add Database Adds additional databases to the Database Explorer Tree.

Refresh Database

Refreshes the objects shown below a database in the tree. Right-click the database to refresh, then choose this command.

Note: Only object types previously expanded are refreshed.

Remove Database

Removes a database from the Database Explorer Tree.

Teradata SQL Assistant for Microsoft Windows User Guide 47

Page 48: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 1: Getting StartedDatabase Explorer Tree

Setting Database Tree Preferences

To set database tree preferences

1 Select Tools > Options.

2 Click the DB Tree tab.

Generate SQL – The commands on this menu generate and insert SQL into the Query window.An example of the inserted SQL is shown for each command below. In these examples

• <name> is the Table or View name

• <a, b, c, ...> is the list of columns in that table or view

Select Select <a, b, c, ...> from <name>.

Insert (Values) Insert into <name> ( <a, b, c, ...>)

Values (<a [datatype], b [datatype], c [datatype], ...>)

Insert (Import) Insert into <name> ( <a, b, c, ...>)

Values (?, ?, ?, ...)

Create Create Table <name>

(

<a [datatype],

b [datatype],

c [datatype]>

)

Primary Index (x)

Table 7: Explorer Tree Shortcut Menu Commands (continued)

Command Description

48 Teradata SQL Assistant for Microsoft Windows User Guide

Page 49: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 1: Getting StartedDatabase Explorer Tree

3 Choose from the options shown in Table 8.

Table 8: Options Dialog Box, DB Tree Tab

Options Description

Load my user defined list of databases

This is the default option. The user DBC, current logon user, default database, and any databases or users previously defined for this data source are loaded.

Load the databases and users from a Table or View

This option is only available when connecting to a Teradata data source. This option reads the database names from the table or view specified in the next field.

Load from this source Enter the name of the table or view to load database names from. By default, this view name is DBC.DatabasesX. If an unqualified name is entered, the assumption is that the name is in database DBC. This table/view must contain the columns ‘DatabaseName’ and ‘DBKind.’ DBKind should be set to ‘D’ to indicate a database. Any other value is assumed to be a User.

Exclude all users except for DBC and myself

The default is selected. When selected, all databases are loaded, and users are excluded. The only users that are loaded are DBC and the current logon user.

Teradata SQL Assistant for Microsoft Windows User Guide 49

Page 50: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 1: Getting StartedFavorites and Examples Pane

Favorites and Examples Pane

The Favorites and Examples pane can be displayed at the left or right side of the main Teradata SQL Assistant window. This pane displays any SQL Sets that you have created, in addition to the syntax examples for any database to which you are connected. Expanding an SQL Set node displays an alphabetical list of the statements in that set. Double-click a statement to Quick-Paste it into your Query at the current insertion point. Alternatively, you may drag the statement and drop it at any point within your Query.

Opening and Closing the Favorites Pane

To open or close the Favorites pane

✔ Do one of the following:

• Select View > Show Favorites.

Save Database Tree information to disk and reload it at startup

The default is cleared. When selected, all the information currently in the database tree is saved to disk before Teradata SQL Assistant is shut down. The database tree information is reloaded when opened again.

The column information automatically loads for all tables and views in the database when you expand the Tables or Views folders in the database tree.

Load only column names for Views - Much faster (Teradata only)

The default is cleared. This option is only available when Save Database Tree information to disk and reload it at startup is selected.

Select this option to load only the column names for Views. Using this option speeds up the amount of time it takes to load database information for a database that contains many views.

Qualify Names when dragged or pasted from the Database Tree

The default is cleared. When selected, Table, Column, etc. names are qualified with their parent name when dragged from the Explorer Tree, or when the Quick Paste menu is used.

Enclose names in quotes when dragged or pasted from the Database Tree

The default is cleared. When selected, names are enclosed in double quotes when dragged from the Explorer Tree, or when the Generate SQL or Quick Paste menus are used.

Use alternate schema when loading the Explorer Tree for Unknown vendors

Select this item if you are connected to an unknown (unsupported) database and no objects appear in the Explorer Tree.

Table 8: Options Dialog Box, DB Tree Tab (continued)

Options Description

50 Teradata SQL Assistant for Microsoft Windows User Guide

Page 51: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 1: Getting StartedFavorites and Examples Pane

• On the Toolbar click .

The check mark displays the status by toggling on or off.

Navigating to the Favorites PaneUse the following procedure to move focus to the Favorites and Examples pane.

To navigate to the Favorites pane

✔ Do one of the following:

• Select View > Go To Favorites.

• On the Toolbar click .

• Press Ctrl+Shift+G.

Changing the Width of the Favorites Pane

To change the width of the Favorites pane

✔ Click on the right edge of the display and drag it to a new position.

Moving the Favorites Pane WindowThe Favorites pane operates as a separate window that can be moved around and docked to the left or right side of the parent window or float independently.

The Favorites pane also has an auto-hide feature that causes it to collapse to a bar when the mouse moves away from the window.

To move the Favorites pane

✔ To move the Favorites pane, do the following:

• Click the caption bar of the Favorites pane and drag it to a desired location. When the cursor is close to the left or right edge of the main window, it displays a bold outline indicating that it is ready to dock to that side. Otherwise it floats when the mouse button is released.

• If the Database Tree and Favorites pane appear as tabs and you only want to move one of them, click on the tab itself and drag it to the desired location.

✔ To auto-hide the Favorites pane, do one of the following:

• Click the push pin on the caption bar to activate auto-hide or “unpin” the Favorites pane.

• When you move the cursor away from the Favorites pane, the window collapses to a bar at the side of the main window. When you move the cursor over the Favorites tab on the bar, the Favorites pane window reopens .

Teradata SQL Assistant for Microsoft Windows User Guide 51

Page 52: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 1: Getting StartedListing All Tables or Views In a Database

• Click the push pin again to turn off auto-hide.

Listing All Tables or Views In a Database

To list the tables or views of any database

1 Do one of the following:

• Select Tools > List Tables.

• On the Toolbar click .

2 In the Database Name field, type the name of the database (or owner, if using Oracle) containing the tables.

Enter the following wildcard characters in this field:

Note: Wildcard characters only function when using an ODBC connection.

• "_" Matches any single character

• "%" Matches zero or more characters

If the name is specified as a single percent sign ("%") this has special meaning to some ODBC drivers. It requests a list of all databases on the system, rather than all Tables within all Databases. To display all tables in all databases it is therefore safer to specify either "%%" or "_%".

Note: This field does not apply to Microsoft Access databases.

3 At least one of the following must be selected:

• Show Tables lists the tables in the selected database.

• Show Views lists the views in the selected database.

The resulting list of tables, views and/or system tables appears in an Answerset window. This window does not automatically close when new queries are submitted.

Listing All Columns In a Table or View

To list the columns in a table or view

1 Do one of the following:

• Select Tools > List Columns.

• On the Toolbar click .

2 In Database Name field, type the name of the database (or owner, if using Oracle) containing the table or view. This field does not apply to Microsoft Access databases.

3 In Table or View Name, type the name of the table or view.

52 Teradata SQL Assistant for Microsoft Windows User Guide

Page 53: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 1: Getting StartedSetting General Program Preferences

The resulting list of columns appear in an Answerset window. This window does not automatically close when new queries are submitted.

Setting General Program Preferences

This section includes information about the following:

• Setting Default File Paths

• Using Page Setup

• Using Print Preview

The following steps explain the available options under the General tab and how to control basic program behavior by setting options.

To set general program preferences

1 Select Tools > Options.

2 Click the General tab.

3 Choose from the options shown in Table 9.

Teradata SQL Assistant for Microsoft Windows User Guide 53

Page 54: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 1: Getting StartedSetting General Program Preferences

Setting Default File Paths

To set default file paths

1 Select Tools > Options.

2 Click the File Paths tab.

Table 9: Options Dialog Box, GeneralTab

Options Description

Allow connections to multiple data sources (Query windows)

Select this box to allow SQL Assistant to connect more than one data source. The Connect icon remains active. The default for this setting is cleared.

Allow multiple queries per connection (Tabs in a query window)

Allows multiple query tabs to be opened within a Query window.

With this option selected, the New Query command opens a new tab in the current Query Window.

The default for this setting is selected.

Print the related SQL when printing an Answerset

Select this option to print the SQL statement that is associated with the Answerset to be printed.

Note: The SQL statement does not display in the Print Preview window but are printed.

Provide extended support for screen readers

Select this option if you are visually impaired and you use a screen reader. This causes your screen reader to announce the contents of the Answerset and History cells as you move from one cell to another.

The default for this setting is cleared.

Use a separate Answer window for

• Each Resultset - opens a new Answer window for each new result set

• Each Query - opens a new Answer window for each new query, but uses tabs within this window if the query returns multiple result sets. This is the default setting.

• Never - directs all query results to display in a single tabbed Answer window

Application Style This option changes the look and feel of SQL Assistant. Choose from Office2000, Office2003, Office2007, Windows Vista or Windows 7. Office 2007 has several color options. The default is Office2003.

Base Font Size Changes the size of the fonts used in the main window and all dialog boxes. Choose between Standard, Larger, and Largest.

54 Teradata SQL Assistant for Microsoft Windows User Guide

Page 55: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 1: Getting StartedSetting General Program Preferences

3 Enter file paths for the options shown. See the table below for option descriptions.

Table 10: Description of the File Paths Options

Option Description

Query files The Open/Save Query functions point to this directory the first time they are used. Subsequent open/save operations point to the most recent directory used.

The default path is C:\Documents and Settings\<user name>\My Documents.

Answer files The Open/Save Query functions point to this directory the first time they are used. Subsequent open/save/export operations point to the most recent directory used.

The default path is C:\Documents and Settings\<user name>\My Documents.

Import and LOB files Import operations initially point to this directory for import files. This is also the default location for storage of any large objects that are retrieved.

The default path is C:\Documents and Settings\<user name>\My Documents.

Teradata SQL Assistant for Microsoft Windows User Guide 55

Page 56: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 1: Getting StartedSetting General Program Preferences

Using Page SetupUse the following procedure to change the way spreadsheet data in the Answerset and History window appears and is printed using the Page Setup dialog box.

To use the Page Setup dialog box

1 Under File, select Page Setup.

2 Use the Page Setup dialog box to set how the page looks. To see how the page looks, click Print Preview. See also “Using Print Preview” on page 57.

History file History information is loaded from the SQLHistory.mdb file stored in this directory.

If you change this path to a directory that does not contain an SQLHistory.mdb file, Teradata SQL Assistant opens and converts any history file created by an earlier version of Teradata SQL Assistant. If a previous version is not found, a new, empty history database is created.

The default path is C:\Documents and Settings\<user name>\Application Data\Teradata\SQL Assistant.

Table 10: Description of the File Paths Options (continued)

Option Description

Table 11: Description of the Page Setup Dialog Box and Print Preview Window

Option Description

Margins Select the margin size for the spreadsheet.

Orientation Select the orientation for the spreadsheet.

Page Size Select the paper size.

Scale Factor Scroll or enter a value between 50 and 200 percent for the scale size of the spreadsheet. The default scale size is 100 percent.

Print in Color Select to print in color. The default is to print in black and white.

Note: This option is also available when printing a Query or output from Explain and Show statements.

Print a border around the data

Select this option to print a border around the spreadsheet data. This option adds a point border around the speadsheet information.

Note: This option is also available when printing a Query or output from Explain and Show statements.

Page Title Enter a title for the page.

56 Teradata SQL Assistant for Microsoft Windows User Guide

Page 57: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 1: Getting StartedSupport for Unicode® and UTF-8

Using Print PreviewThe Print Preview dialog box allows you to preview Answerset or History window spreadsheet data before printing. Print preview is only available from the Answerset window and the History window. These two windows print data in the form of a spreadsheet. You can print the Query window, but print preview is not available.

To use the Print Preview window

✔ Do one of the following:

• Select Print Preview under File from the Toolbar.

• To view one or more pages at a time, use the page icon .

• Use the Zoom icon to change the view size.

• To print, click the Print icon .

• View a different page by using the select page field .

Support for Unicode® and UTF-8

The Teradata data source must be defined to use either a UTF-8 or UTF-16 session character set in order to successfully submit or retrieve Unicode® data.

CLOBs can not be retrieved over a UTF-8 ODBC connection. CLOBs can be retrieved over a UTF-16 ODBC session if the ODBC option Use native LOB support is selected.

If this option is not selected, or if working with Teradata Database V2R5.0 or lower, all fixed length character data may be returned with additional blank padding up to a length of double the actual column size. This limitation is caused by insufficient descriptive information returned to the driver from older Teradata Database releases.

The following sections contain related information.

• Displaying Unicode® Data

• Exporting Unicode® Data

• Importing Unicode® Data

Displaying Unicode® DataTo display languages such as Arabic or Hebrew, which are normally displayed from right to left, use the Regional Settings option of Windows Control Panel to install the required language support files.

Exporting Unicode® DataTo export to a text file, select an Export file type of Delimited Text [UTF-8] or Delimited Text [Unicode].

If Delimited Text (ASCII) is selected, any data that is not a part of the code page is corrupted.

Teradata SQL Assistant for Microsoft Windows User Guide 57

Page 58: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 1: Getting StartedSupport for the Visually Impaired

Note: Teradata CLOBs over 2K in size can only be returned through an ODBC connection if the UTF-16 character set was specified in the Connection dialog box.

Importing Unicode® DataImported files can be in ASCII, Unicode (UTF-16), or UTF-8 format. (If Unicode or UTF-8 the file MUST contain the appropriate Byte Order Mark prefix.)

When Importing CLOB data, the data files referenced in the Import file can be in ASCII, Unicode (UTF-16), or UTF-8 format. All files destined for a specific column should however be of the same type.

Support for the Visually Impaired

SQL Assistant provides a number of features for the visually impaired:

• Text Size

• Color scheme

• Audible support

• General Command Shortcut Keys

Text SizeThe General tab of the Options dialog box allows the selection of a Larger or Largest font size. These increase the size of the default font, and the dialog boxes themselves, by 25% or 50% respectively.

In addition, both the font and the font size may be changed in the Query, Answerset and History windows. You may also temporarily increase or decrease the size within these windows by pressing the Ctrl key while spinning the mouse wheel or pressing the +/- keys.

Color schemeThe General tab of the Options dialog box allows the selection of the Application style. This controls the colors used throughout the application. If using one of the Windows High Contrast options, select System Default as the application style.

The colors used in the Query window are independent of the Application style settings. Change these colors using the Display Item list with the Color control, on the Code Editor tab of the Options dialog box.

Audible supportIf using a screen reader, select the Provide extended support for screen readers check box on the General tab of the options dialog box. This causes the screen reader to announce the contents of each cell as you move through the cells of an Answerset or History window.

For a sound to be played whenever a query ends, select the Provide audible notification when a query ends check box on the Query tab of the options dialog box.

58 Teradata SQL Assistant for Microsoft Windows User Guide

Page 59: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 1: Getting StartedLimitations

Limitations

The following sections list limitations with Teradata SQL Assistant:

• General Limitations

• Teradata.NET Specific Limitations

• Oracle.NET Specific Limitations

• ODBC Specific Limitations

Please refer to the release notes for the latest information.

General LimitationsExported text files always have BOM prefixes if they are written in UTF-8 or UTF-16.

Teradata.NET Specific Limitations• A WITH (summary) clause in a Select statement causes the data return to fail.

• TD.NET always uses ANSI date mode. All date literals must be entered as YYYY-MM-DD.

• Timestamp With Time Zone columns only sort correctly if you use a date format of YYYY-MM-DD.

Oracle.NET Specific Limitations• Decimal columns with more than 28 digits may be displayed as <Error>.

• You must use the correct case for Database/User names (generally Uppercase)This applies to the Connection dialog box, when adding Databases to the Explorer tree, or when enclosing object names within double quotes.

• Create Procedure statements must end with a semicolon.These statements create, but not compile, the procedure.You must compile the procedure before it can be executed.

ODBC Specific Limitations

General• Time fields do not display fractional seconds or Time Zone information.

• Decimal values with more than 28 digits may display incorrectly.

• Retrieving Interval data or vendor specific types may limit the functionality of the resultset as follows:

• Decimal data may display 'n' decimal places ('n' is the value for Float data in Options).

• Date columns may be displayed as Timestamps and may not use your selected format.

• BLOB/CLOB columns may be displayed as regular BYTE/CHAR data.

Teradata• CLOBs can only be returned using the UTF-16 Session Character Set (unless < 2K).

Teradata SQL Assistant for Microsoft Windows User Guide 59

Page 60: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 1: Getting StartedLimitations

• Only type 'F' User Defined Functions are listed in the Database Explorer Tree.

• FLOAT columns may be reported as 'TIME' in the Database Explorer Tree if they have a Format clause that looks like a time, for example, '99:99:99'.

• If a macro (or execute parallel) returns zero rows from a Select statement, no rows are returned from any later Select statements in that macro or parallel query.

DB2In order to return BLOBs and CLOBs correctly you must either set LongDataCompat=1 in the db2cli.ini file or use Define ODBC Data Source dialog box to set this option in the Data Source itself.

• Open the Define ODBC Data Source dialog box and select the data source and click Configure.

• Click Add on the Advanced tab and select LongDataCompat from the list.

• Select the As LongVarchar data option.

Oracle• Procedure and Function parameters are not displayed in the Database Explorer Tree.

• Retrieval of INTERVAL or other 'unknown' types causes the ODBC driver to crash.

• .NET cuts off the first byte when selecting columns defined as RAW(n). This renders the binary object useless. Define the columns as BLOB instead.

PostgreSQLImport only works if all columns can be converted to CHAR type (PostgreSQL has no ability to convert a string to a numeric for example).

MySQLYou must use MySQL Connect/ODBC 3.51.27, not 5.1.5 (future versions might remove this limitation). The older 5.1.x ODBC drivers do not return catalog information (tables and columns, for example).

60 Teradata SQL Assistant for Microsoft Windows User Guide

Page 61: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

CHAPTER 2

The Query Window

The purpose of this section is to explain how to use the Query Window and its features and functions, as well as how to import data. This section contains the following information:

• Introduction to the Query Window

• Using the Query Window

• Entering and Executing Queries

• Working With SQL Text in the Query Window

• Displaying an Explain Plan of a Query

• Query Builder Overview

• Scheduling Queries for Later Execution

• Formatting a Query

• Importing Data

• Using the Query Window Shortcut Menu

Introduction to the Query Window

The Query Window is a fully functional editing environment that can be used to edit and execute queries. Some of the features the editor supports are:

• Drag-and-drop editing.

• Automatic syntax coloring and brace matching. See “Setting Code Editor Options” on page 67.

• Converting of selected text to either upper or lower case. See “The Query Toolbar” on page 166.

• Inserting or deleting bookmarks. See “Selecting Text and Inserting Bookmarks Using the Query Window Margin” on page 63.

• Making white space characters visible. See “The Query Toolbar” on page 166

• Recording and playing back of keystroke macros. See “Recording and Executing Query Window Macros” on page 79.

• A full compliment of command and cursor control shortcut keys. See “General Command Shortcut Keys” on page 177 and “Window Control Shortcut Keys” on page 181.

The results from the query are placed into one or more Answerset windows. Alternatively, the results may be written directly to a file.

Teradata SQL Assistant for Microsoft Windows User Guide 61

Page 62: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 2: The Query WindowUsing the Query Window

Queries may consist of one or more statements, and may return zero or more Answersets. Enter SQL, DDL, or DML into the Query Window.

Comments may be added to queries. These comments are stored in the history database as part of the query.

When the Query Window is active, the menus, commands, and tools available pertain only to that window.

Using the Query Window

This section explains how to use the Query Window. Topics covered include the following:

• Using SQL, DDL, and DML Statements

• Displaying the Query Window Toolbar

• Allowing Multiple Queries

• Splitting the Query Window into Two Windows

• Selecting Text and Inserting Bookmarks Using the Query Window Margin

• Creating Statements (Single and Multi)

• Parameterized Queries

• Magnifying the Query Window

• Setting Query Options

• Setting Code Editor Options

Using SQL, DDL, and DML StatementsThe SQL, DDL, and DML statements should conform to the syntax defined with the ODBC or Teradata .NET data sources.

Displaying the Query Window ToolbarFollow this procedure to display or hide the Query Window toolbar.

To display the Query Window toolbar

✔ Do one of the following:

• Select View > Toolbars > Query.

• Right-click anywhere in the Menubar or toolbar, then select Query on the popup menu.

Allowing Multiple QueriesTeradata SQL Assistant allows you to connect to multiple data sources. Each connection opens a separate Query window. You can also have multiple queries within a Query window. Each query opens a new tab in the Query window.

62 Teradata SQL Assistant for Microsoft Windows User Guide

Page 63: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 2: The Query WindowUsing the Query Window

The following procedure explains how to open both multiple Query windows and multiple tabs.

To allow multiple queries

1 Go to Tools > Options and select the General tab.

2 Choose one or both of the following options:

• Allow connections to multiple data sources (Query window)

• Allow multiple queries per connection (Tabs in the Query window)

3 Click the New Query icon . A new tab opens in the current Query window.

4 Click the Connect... icon to open an additional data source. This opens a new Query window. See “Connecting to and Disconnecting from a Data Source” on page 30 for more information on data sources.

Splitting the Query Window into Two WindowsSplit the query window into two independent scrolling windows to view two different parts of the query at once.

To split the Query Window into two scrolling windows

✔ On the right side of the Query Window, drag the bar at the top of the vertical scroll bar downwards.

Selecting Text and Inserting Bookmarks Using the Query Window MarginAnother shortcut is to use the margin at the left of the Query Window. Use the margin to select text, and insert or delete bookmarks.

To select text and insert or delete bookmarks using the margin of the Query Window

✔ To select text and insert and delete bookmarks, do one of the following:

• Click in the margin to highlight the corresponding line.

• Click and drag in the margin to highlight multiple lines.

• Double-click in the margin, press Ctrl+B, or click to toggle a bookmark on or off for that line.

Creating Statements (Single and Multi)Queries may be created that consist of one or more statements.

A semicolon is not required when one statement at a time is entered. However, a semicolon between the statements is required for two or more statements.

Teradata SQL Assistant for Microsoft Windows User Guide 63

Page 64: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 2: The Query WindowUsing the Query Window

Each statement in the query is submitted separately to the database, therefore, the query may return more than one Answerset.

Parameterized QueriesQueries may contain Named Parameters, which makes it easy to reuse a query because all that changes are the data values (for example, in a Where clause).

Named Parameters function like variables. Enter the value for a named parameter once. If it is used in multiple places within the query that same value is used in all places.

Note: The values entered for named parameters are saved to the Notes column of History for future reference.

Named Parameters are indicated by a “?” immediately followed by a name. The name can consist of alphanumeric characters plus the “_” symbol.

When an parameterized query is executed, a prompt appears for each parameter before the query is submitted.

For example, if the following query is submitted:

Select * From PhoneBook Where LastName Like '?NameStart'

A prompt appears to enter a value for NameStart.

Parameter values are directly inserted into the query. This means that they may need to be enclosed in quotes. Although quotes may be used when prompted for the data value, it is generally recommended that quotes be included in the query itself, as in the example above. See “Setting Query Options” on page 65 for more information.

To switch off parameter substitution

1 Select Tools > Options.

2 Select the Query tab.

3 Clear the option Allow use of Named Parameters in queries.

Note: If an empty string is entered, or the Cancel button used, the query is left unchanged. This allows for those rare cases where SQL Assistant incorrectly identifies a regular part of the query as being a parameter name.

Magnifying the Query WindowUse the following procedure to change the magnification of a window.

To magnify the active window

1 Make sure the window is active.

2 Hold the Ctrl button and rotate the mouse wheel or press the + or - keys. The display zooms in and out.

64 Teradata SQL Assistant for Microsoft Windows User Guide

Page 65: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 2: The Query WindowUsing the Query Window

3 To restore the zoom level to its original size (100%) press Ctrl+0.

Setting Query OptionsUse the following procedure to control queries by setting options on the Query tab.

Note: The SQL Assistant option Allow use of ODBC SQL Extensions in queries no longer exists. Clear the ODBC Data Source option Disable Parsing to allow the use of ODBC SQL Extensions.

To set query options

1 Select Tools > Options.

2 Select the Query tab. Table 12 explains each option in the Query tab.

Table 12: The Query Tab in the Options Dialog Box.

Option Description

Close the Answerset window before submitting a new query

The default value is selected. Closes all Answerset windows that are not marked as Do not Close before running a new query.

Teradata SQL Assistant for Microsoft Windows User Guide 65

Page 66: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 2: The Query WindowUsing the Query Window

Disconnect from database when a query ends

The default value is cleared. When selected, this option starts and stops the connection to the data source with each query.

Note: When using this mode, all transactions must be committed or rolled back within the query that started them.

Provide audible notification when a query ends

The default is cleared. When selected, Teradata SQL Assistant makes a sound when a query is complete. The sound also occurs if the query times out, the number of rows exceeds the output limit, or the query is canceled.

This option is also available from the Toolbar by clicking .

Minimize SQL Assistant while a query is running

The default is cleared. When selected, Teradata SQL Assistant minimizes when a query runs.

Prompt for a note before running a query

The default is cleared. When selected, Teradata SQL Assistant displays a dialog box to enter notes whenever a query is submitted. Also, from the Toolbar, click (you can toggle this option on or off).

To add a note after the query has completed, double-click the note cell, or click the cell and press Enter. The Query Note dialog box opens.

Stop query execution if an SQL error occurs

The default is selected. When selected, queries are stopped if an error occurs even if the query contains additional statements that have not yet been executed.

If a query with conditional logic based on the ERRORCODE command is used, clear this option. If this option remains selected, Teradata SQLA stops processing the query before it attempts to evaluate the conditional logic.

Queries with conditional logic based on ERRORCODE and ending with an EXIT command are reported as successful if the return code is zero.

Submit only the selected query text when highlighted

The default is cleared. This means even if part of the query is highlighted, the entire query is executed when submitted.

Allow use of Named Parameters in queries.

The default is selected. This setting allows the use of Named Parameter substitution in queries.

Prompt to save the Query Log when a Query ends

The default is cleared. When selected, Teradata SQL Assistant displays a dialog box that allows the Query Log to be saved after a multi-statement query is executed.

Prompt to save queries that have been changed, but not run, before closing

The default is selected. When selected, Teradata SQL Assistant displays a dialog box to save the Query to either a file or to the History database before closing the Query window or closing Teradata SQL Assistant.

A prompt to save the query only displays if changes were made to the query since opening a file, saving to a file, executing the query, copying a query from the History window by clicking on the SQL, or using the Clear Query button.

Table 12: The Query Tab in the Options Dialog Box. (continued)

Option Description

66 Teradata SQL Assistant for Microsoft Windows User Guide

Page 67: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 2: The Query WindowUsing the Query Window

Setting Code Editor OptionsQueries can be automatically colorized as you type, using the Code Editor tab in the Options dialog box. The query text is colorized based on specific SQL keywords and functions, strings and numbers, comments, etc. Query syntax and parser errors are highlighted in yellow by default in the Query window. This color can be changed in the Code Editor tab.

To set formatting options for a query

1 Select Tools > Options.

2 Select the Code Editor tab.

3 Choose an option. The following table explains each option.

Note: For more information on how syntax highlighting works, see “Language Definition Files” on page 93.

Note: Japanese object names are only highlighted as object names if they are enclosed in double quotes.

Teradata SQL Assistant for Microsoft Windows User Guide 67

Page 68: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 2: The Query WindowUsing the Query Window

Table 13: Code Editor Tab in the Options Dialog Box

Option Description

Automatic syntax highlighting Enables syntax highlighting. If this option is not selected, all text is set to the default color. The default is selected.

Note: Disabling this feature also turns off automatic brace matching.

Convert keywords to upper case Displays all keywords in uppercase. The default is cleared.

Display line numbers Displays line numbers to the left of each line in the query.The default is cleared.

Display left margin Displays the left margin in the Query window.The default is selected.

Display brace matches If this option is selected, keywords (such as BEGIN and END), symbols, parenthesis, and quotation marks are highlighted as a pair when the cursor is placed within or after a keyword. The default is selected.

Insert spaces for tabs Inserts ‘n’ space characters each time the tab key is pressed. Use the Tab Size box to indicate the number of spaces for each tab entered, from 2-9. The default is cleared.

Indent new lines like previous The default is selected. If this option is not selected, all new lines start at the left margin.

Wrap lists after When using Format Query, any comma that is found after this column causes the remaining text on that line to be moved to a new line. To format the query so that each column in the select list is on a separate line, set to a low value such as three.The default is 60.

Display suggestions If this option is selected SQL Assistant displays drop down lists containing object and built-in function names. The default is cleared.

See “Using Code Completion” on page 71.

Include table names This option applies only if Display suggestions is also selected. When selected, both Table and View names are included in the object name lists. When cleared, only Views are included. The default is cleared.

68 Teradata SQL Assistant for Microsoft Windows User Guide

Page 69: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 2: The Query WindowEntering and Executing Queries

Entering and Executing Queries

This section provides information about the following:

• Entering a Query

• Using Conditional Logic in a Query

• Using Code Completion

• Customizing Code Completion Lists

• Executing a Query

• Using Transactions

• Running Multiple Queries

• Executing Multiple Statements in Parallel

• Submitting Part of a Query

• Aborting a Query in Progress

• Executing a Query Saved To a File

• Automatically Minimizing the Teradata SQL Assistant Window

• Renaming a Query Tab

• Deleting a Query Tab

Entering a QueryAfter establishing a connection to a data source (refer to “Connecting to and Disconnecting from a Data Source” on page 30), Teradata SQL Assistant is ready to execute queries. (Queries can be entered before a connection is established.)

Display Item Shows a list of syntax elements and other application settings. Select an item to see its current color displayed in the Color field to the right. Its font style is indicated by the bold and italicized check boxes below.

Change the color by clicking the dropdown button of the Color list and selecting a new color from one of the three tabs:

• Custom tab - Select one of the displayed colors, or right-click in the bottom 2 rows to display the Windows custom color dialog box, which allows you to define your own color.

• Web tab -These are colors commonly found in web pages.

• System tab - Standard System colors.

Change the font style by selecting or clearing the two check boxes.

Note: The font style options are only available for the query syntax highlighting colors.

Table 13: Code Editor Tab in the Options Dialog Box (continued)

Option Description

Teradata SQL Assistant for Microsoft Windows User Guide 69

Page 70: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 2: The Query WindowEntering and Executing Queries

To enter a query

✔ Do one of the following:

• Click within the Query Window and enter a statement.

• On the Toolbar click , and enter a statement in the new Query tab.

• Select File > New Query and enter a statement in the new Query tab.

• Press Ctrl+N and enter a statement in the new Query tab.

• From the History window, select any statement from the SQL statement column.

The Execute command submits the query currently in the Query Window to the database. Each statement in the query is submitted separately to the database. By default, queries are submitted asynchronously and can be aborted while they are executing.

Using Conditional Logic in a QueryThe following conditional logic commands may be used within queries.

Table Legend• { }–Items in curly brackets are requirements.

• [ ]–Items in square brackets are optional.

• label–A string that does not contain any blank spaces or tabs.

• oper–One of the following operators:

• n–An integer.

• value–Any string.

• filename–A fully qualified file name.

= > < >= <=

<> != ^= ~=

Command Description

.IF {ACTIVITYCOUNT} oper n [THEN] {.GOTO label}

{ERRORCODE } {.EXIT [n] }

If the condition is true, the action is performed. Otherwise the flow continues to the following statement.

This command can not be used before the first SQL statement.

.GOTO label The next statement executed is the statement following the .LABEL command.

.LABEL label Defines the destination of a .GOTO command.

[ n ]

.EXIT [ ERRORCODE ]

[ ACTIVITYCO[UNT]]

Execution terminates at this command. The optional parameter is used as the result code for the query. Zero indicates a successful query, any other value indicates failure.

70 Teradata SQL Assistant for Microsoft Windows User Guide

Page 71: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 2: The Query WindowEntering and Executing Queries

Usage Notes• The period (.) before the RUN command is optional for backward compatibility.

• The period (.) before other commands (except .SET) is optional when connected to a Teradata Database, but required when connected to other databases.

• The period for the .SET command is mandatory even when connected to a Teradata Database.

• [Optional] All commands can be followed by a semi-colon. This is not required unless you need compatibility with BTEQ.

• To use conditional logic commands based on the ERRORCODE, you must first disable the Stop query execution if an SQL error occurs option on the Query tab of the Options dialog box. Otherwise Teradata SQL Assistant may stop processing the query before it attempts to evaluate your conditional logic. See “Setting Query Options” on page 65.

Using Code CompletionSQL Assistant can provide suggestions for the object and built-in function names that can be used.

A drop down list appears after certain keywords and delimiters are entered. As you continue to enter the object name, the first item to match is selected in this list. When the item you want is selected, type a comma, space, tab, open parenthesis, or Enter to select and insert that name into your query.

Code completion only appears after the keywords and delimeters used within the common Select, Insert, Update and Delete statements are entered. To display a selection list at any other time, press Ctrl+Space.

Code completion works differently in SQL Assistant than it does in other editors. SQL Assistant uses the concept of a current database. Initially the current database is set to the default database for the data source. Change this setting by right clicking on a database in the Database Explorer tree, then clicking the Use for View Names menu.

When the FROM clause is entered, the suggestion list contains all the views, and optionally the tables, in the current database in addition to all the databases currently in the Database Explorer tree under this data source.

SQL Assistant also builds an active list. Each time table or view name in the FROM clause is entered, that object, along with any alias name, is added to the active list. When entering the

.QUIT Performs the same function as the .EXIT command.

.SET value This command is for BTEQ compatibility only. This command is ignore. Unlike BTEQ, The .SET prefix is required for Teradata SQL Assistant to recognize and ignore a command.

.RUN filename Execute the query contained in the specified filename. The RUN command must be the first and only statement executed.

Command Description

Teradata SQL Assistant for Microsoft Windows User Guide 71

Page 72: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 2: The Query WindowEntering and Executing Queries

Select and Where clauses, these alias names and the columns contained in the objects within the active list appear.

Because objects and their columns are not added to the active list until they have been entered in the FROM clause, type theFROM clause before the remainder of the statement.

The active list continues to grow as additional Select statements or sub-selects are entered. This means that you do not need to enter the FROM clause of your second statement before other parts of the statement if your previous statements referenced the same tables. However, if you switch to a completely different set of tables and views, reduce the size of the dropdown lists by clearing out the active list by right clicking on the data source in the Database Explorer tree and selecting the Clear Column List menu.

Note: If you use the Teradata form of the FROM clause (a simple comma separated list), the last name in the list is not be added to the active list unless you press Ctrl+Shift+Space after the last View/alias name or type the start of the Where clause.

To Display suggestion lists

1 Select Tool > Options.

2 Select the Code Editor tab.

3 Select Display Suggestions.

4 [Optional] Select Include Table names.

Only Views are listed if this option is cleared.

Note: Selecting the Display suggestions option automatically switches on the DB Tree option Save Database Tree information to disk and reload it at startup. To avoid serious performance impact when the Tables or Views node of a database is expanded, select the DB Tree option Load only column names for Views.

Customizing Code Completion ListsThe list of built-in functions that appear in the code completion drop down lists is vendor specific. Currently only two sets of lists are provided, one for Teradata and one for all other databases. This second set is also used when View > ANSI SQL is selected.

These lists are defined in files named Teradata.mbr, TeradataA.mbr, Base.mbr and BaseA.mbr and are located in

\Documents and settings\<user>\Application Data\Teradata\SQL Assistant

The files that contain the A suffix in the filename contain the aggregate functions. The files without the suffix contain the non-aggregate functions.

If you regularly work with another database such as Oracle, you can create your own lists specifically for use with that database type (for example, Oracle.mbr and OracleA.mbr).

You may also edit the existing mbr files to remove the functions you never use or add your own User Defined Functions (UDFs). These are simple XML text files containing a single element type with 2 attributes:

72 Teradata SQL Assistant for Microsoft Windows User Guide

Page 73: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 2: The Query WindowEntering and Executing Queries

• name is the text that appears in the dropdown list.

• help is an optional string that appears in a tooltip when a list item is selected.

Executing a Query

To execute a query

✔ Do one of the following:

• On the Toolbar click .

• Select Tools > Execute.

• From the Query Window, right-click and select Execute.

• Press F5.

Results from the query appear in one or more Answerset windows.

When you submit a query the background color of the tab, and query, change to the Query is Running color (default pale red), the query text is protected, and the current status is shown on a Query Status Bar, below the Query window.

If the query contains more than one statement it is replaced by a log that shows the progress of the query. In this case, a button appears at the far right of the query status bar, below the Query window, that allows you to toggle the display between the log and the query itself. The currently executing statement is selected and the Query window scrolls to bring this statement to the top.

When a query completes, if the executing tab is the active tab, the background color reverts to its default color. If another tab is active, the background color changes to green to indicate that the query in that tab has ended. In this case the color reverts to its default color when you click on the tab.

Using TransactionsIn most cases, use the vendor provided statements for Beginning, Committing, or Rolling back transactions.

If you are using ANSI Transaction mode with Teradata, the data connectivity tools auto-commit each statement. In order to create transactions in this mode, use the following SQL Assistant specific commands:

Command Usage

.BeginTx Starts a transaction

.CommitTx Commits the transaction

.RollbackTx Rolls back all changes made within the transaction

Teradata SQL Assistant for Microsoft Windows User Guide 73

Page 74: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 2: The Query WindowEntering and Executing Queries

If you attempt to disconnect or close the Query window while a transaction is in progress, it asks whether the transaction should be committed or rolled back.

Note: Do not execute multiple queries at the same time within a single Query window while using transactions, unless the entire transaction is contained within a single query, because multiple queries execute within different sessions and there is no way to control which session executes which query.

Running Multiple QueriesMultiple queries can run at the same time, either from multiple tabs within one Query window, or from multiple Query windows. Each Query is executed in its own thread and has no impact on other concurrently running queries, or on the user interface. Data retrieval however, is all performed in the main thread so the user interface may be slow to respond while results are returned.

Note: If you run multiple queries from different tabs within the same Query window, SQL Assistant temporarily connects additional sessions using the same connection information you entered for the initial connection. No special context is available to these additional sessions however, so do not assume that the default database (if you have changed it) or temporary tables, are available. If your queries rely on the default database, or on the existence of temporary tables, you should execute/run only one query at a time from within a specific Query window. This ensures that each query uses the same session that was used by the previous query.

Executing Multiple Statements in ParallelExecuting multiple statements from the Query Window to the database Using the Execute Parallel command. This executes the entire query as a single request, allowing the database to execute all the statements in parallel. Multiple Answersets may be returned in the Answerset window.

Note: To submit a Transact-SQL script containing semi colons to a Microsoft SQL Server or Sybase database, use the Execute Parallel command.

To execute statements in parallel

1 Enter multiple statements in the Query Window.

2 Do one of the following:

• Select Tools > Execute Parallel.

• On the Toolbar click .

• Press F9

74 Teradata SQL Assistant for Microsoft Windows User Guide

Page 75: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 2: The Query WindowEntering and Executing Queries

Submitting Part of a Query

To submit any part of any query

1 Select Tools > Options.

2 Select the Query tab.

3 Select the option Submit only the selected Query text, when highlighted.

4 From the Query Window, select part of the query by highlighting it.

5 Do one of the following:

• From the Toolbar, click .

• Press F5.

Note: While the query is executing, only the part of the query that you executed has a red background, but the entire query is read only.

To submit the first part of a multistatement query

✔ Insert an EXIT statement within the query by inserting the word EXIT following the semicolon that ends the last statement to process.

Note: The word EXIT must be the next non-whitespace / non-comment text after the semicolon that ends the last part of the query being submitted. It must also be on a new line, optionally preceded by whitespace.

Aborting a Query in ProgressWhen the query is submitted, the Abort menu and tool button are enabled so that the query can be aborted if necessary.

If performing a task that loads objects into the Database Explorer Tree, this task can also be aborted.

To abort a query in progress

✔ Do one of the following:

• Select Tools > Abort.

• From the Toolbar, click .

If a SELECT statement is aborted before all rows are returned, the number of rows reported is the total number of rows matching the query rather than the actual number returned before the abort. This applies only to databases, such as Teradata, that provide this information.

Teradata SQL Assistant for Microsoft Windows User Guide 75

Page 76: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 2: The Query WindowEntering and Executing Queries

Executing a Query Saved To a FileTo simplify the use of large queries and for those who store their queries in a file, enter the following query where <filename> is the fully qualified name of a file containing the query to execute.

RUN <filename>

For example, RUN c:\temp\myquery.sql

The run statement must be the only statement in the Query Window. Optionally, a filename may be followed with a semicolon, then all text between the word RUN and the optional semicolon are assumed to be a part of the file name.

The query is processed exactly as though it had been entered in the Query Window, but the SQL stored in the history file is the run statement itself, not the actual query that was executed.

Automatically Minimizing the Teradata SQL Assistant WindowThe following procedure explains how to automatically minimize the Teradata SQL Assistant window when a query is being processed.

To automatically minimize the Teradata SQL Assistant window

1 Right-click in the Query Window.

2 Click Minimize on Execution.

The Teradata SQL Assistant window minimizes when the query is being processed.

This command remains in effect until Minimize on Execution is clicked again to cancel it.

Renaming a Query TabWhen Query windows appear in tabs, you can change the name of each tab. The following steps explain how.

To rename a Query tab

1 Right-click on the query tab and select Rename from the displayed popup menu.

2 Enter a new name.

Deleting a Query TabWhen queries appear in tabs, individual tabs and their contents may be deleted. The following procedure explains how.

76 Teradata SQL Assistant for Microsoft Windows User Guide

Page 77: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 2: The Query WindowWorking With SQL Text in the Query Window

To delete a Query tab

✔ Right-click on the tab and select Delete from the displayed popup menu.

Working With SQL Text in the Query Window

This section provides the following information about working with SQL text in the Query Window:

• Copying SQL from Previous History Record to the Query Window

• Copying SQL from Next History Record to the Query Window

• Preventing Queries from Being Saved in the History Window

• Undoing or Redoing Query Window Changes

• Setting Repeat Count

• Recording and Executing Query Window Macros

• Saving a Query

• Performing a Quick Save

• Adding a Query to Favorites

• Opening a Query from a File

• Copying a Query to Notepad

• Printing a Query

• Adding Comments to Queries

• Highlighting a block of Text

• Showing Whitespace

• Converting Tabs to Spaces

• Indenting Lines in a Query

• Using the Right-to-Left Editor for Queries

• Deleting Blank Lines from a Query

• Finding a Text String in the Query Window

• Replacing a Text String in the Query Window

Copying SQL from Previous History Record to the Query WindowSQL may be copied from the previous History record to the Query Window. The following steps explain how.

To copy the SQL from the previous row

✔ Do one of the following:

• Select View > Previous SQL.

Teradata SQL Assistant for Microsoft Windows User Guide 77

Page 78: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 2: The Query WindowWorking With SQL Text in the Query Window

• Press F7.

The history SQL either replaces what was previously in the current Query tab, or appears in a new Query tab if the query had been changed.

Copying SQL from Next History Record to the Query Window SQL may be copied from the next History record to the Query Window. The following procedure explains how.

To copy the SQL from the next history row

✔ Do one of the following:

• From the View menu, select Next SQL.

• Press F8.

The history SQL either replaces what was previously in the current Query tab, or appears in a new Query tab if the query had been changed.

Preventing Queries from Being Saved in the History WindowQueries are normally inserted into the History window and the supporting Microsoft Access table for later recall and use. If you do not want the History window updated with each query, you can change an option.

To prevent queries from being saved in the history window

1 Select Tool > Options.

2 Select the History tab.

3 Clear the option record queries and metadata in the History Database.

Undoing or Redoing Query Window ChangesYou can undo or redo the changes made in the Query Window.

To undo or redo a change in the Query Window

✔ Select Edit > Undo (Ctrl-Z) or Edit > Redo (Ctrl-Y).

Setting Repeat CountKeystrokes, macros, and shortcut keys may be set to repeat ‘n’ times in a query.

78 Teradata SQL Assistant for Microsoft Windows User Guide

Page 79: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 2: The Query WindowWorking With SQL Text in the Query Window

To set repeat count

1 Press Ctrl+R, or click on the Query Window toolbar. (For more information, see “Displaying the Query Window Toolbar” on page 62).

The Set Repeat Count dialog box displays.

2 Enter the number of times to repeat the selected keystrokes, shortcut keys or macros.

Recording and Executing Query Window MacrosTo simplify repetitive tasks you can record macros containing multiple keystrokes, then play back these macros at any time in the Query Window.

To record a Query Window macro

1 Press Ctrl+M or click on the Query Window toolbar. (For more information, see also “Displaying the Query Window Toolbar” on page 62.)

The cursor changes to signal the macro is being recorded, and a small Record Macro window pops up displaying a Stop Record button.

2 Enter the desired keystrokes, including text and shortcuts.

3 When finished, click on the Record Macro window to halt recording.

The Save Macro window appears.

4 Press the shortcut key combination with which you want to trigger the macro, and it displays in the Press new shortcut key field.

5 Click the Save as pull-down menu and select the number to use for saving this macro.

To play back a Query Window macro

1 If you want the macro to execute multiple times, click , then in the Set Repeat Count window enter the desired number of repetitions.

2 Click or press Ctrl+E to play Macro 1, or use the shortcut key combination defined when you saved the macro to execute that macro. If you set a repeat count, the macro executes that many times.

To delete all Query Window macros

✔ Click to delete all currently recorded macros and their associated shortcut keys.

Teradata SQL Assistant for Microsoft Windows User Guide 79

Page 80: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 2: The Query WindowWorking With SQL Text in the Query Window

Saving a QueryThere are three ways to save queries in Teradata SQL Assistant, the basic Save, Save As, and a Quick Save. The following procedure explains Save and Save As. See also “Performing a Quick Save” on page 80.

To save a query

1 From an active Query Window, do one of the following:

• Select File > Save As

• Select File> Save

• Click or .

• Press Ctrl+S

2 In the Save Query dialog box, enter a file name.

3 From the Save As Type menu, choose the file type:

• SQL (.sql)

• definitions (.ddl)

• text (.txt)

• rich text format (.rtf)

• Unicode Text (.txt)

Note: The file types listed in the Save Query dialog box are only suggestions. If you want Teradata SQL Assistant to automatically launch when you double-click the file, choose either the .sql or .ddl file type. To store the colors as well as the text so it can be viewed by most word processing applications, choose the .rtf file type.

4 Choose a location, and click Save.

Performing a Quick SaveA Quick save is enabled once a query has been previously saved. The Ctrl+S and Save tool button both activate a Quick save.

During a Quick save, you are not prompted to select a file name if that query tab has already been saved before.

However, using the Save As menu always prompts you for a file name. If you have not saved the query tab before (or have clicked the Clear Query button since the last Save), you are prompted for a file name even if you click Save or press Ctrl+S.

Adding a Query to FavoritesYou can add the current query or selected text to a Favorites collection. Once the query is added as a favorite, it can be selected for reuse from the Query Builder window.

80 Teradata SQL Assistant for Microsoft Windows User Guide

Page 81: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 2: The Query WindowWorking With SQL Text in the Query Window

To add a query to favorites

1 From the Query Window, do one of the following:

• Right-click over the query to display the shortcut menu. Then select Add to Favorites.

• Click .

2 The Add to Favorites dialog box displays.

3 Select or enter the name of the SQL Set to which you want to add this query. The default SQL Set is Favorites.

4 Enter an item name in the Item Name field.

Opening a Query from a FileYou can open a query that was previously saved to a file. The file may be in ASCII, UTF-8, RTF or Unicode format.

To open a query from a file

1 Do one of the following:

• Select File > Open Query.

• From the Toolbar, click .

• Press Ctrl+O.

2 Browse your drive and select the file.

3 Do one of the following:

• Click Open. The contents of the file are inserted into the Query Window.

• Select File > Open Recent Query, then click on the file that contains your query.

Note: As a one-step alternative, drag and drop the file from File Manager or Windows

Explorer into the Query window.

Copying a Query to NotepadYou can copy a specific part of a query or the entire query to Notepad by using the Copy to Notepad command. This command starts the Notepad application and copies the query.

To copy a specific part of a query

1 From the Query Window, highlight the specific part of the query you want to copy.

2 Do one of the following:

• Select File > Copy to Notepad.

• From the toolbar, click .

If you do not highlight any part of the query, the entire query is copied to Notepad.

Teradata SQL Assistant for Microsoft Windows User Guide 81

Page 82: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 2: The Query WindowWorking With SQL Text in the Query Window

Printing a QueryYou can print a query in the Query Window using the Windows Print dialog box.

To print a query

1 From the active Query Window, do one of the following:

• From the Toolbar, click .

• Select File > Print Query.

• Press Ctrl+P.

The standard Windows Print dialog box appears. Printers are configured through this Print dialog box.

2 Choose from the following:

• To print the entire query, under Print Range, select All.

• To print a partial query, go to the Query Window and highlight the part you want to print. Under Print Range, select Selection.

Cancel print jobs through the Print Manager. For more information, see “Cancelling Print Jobs” on page 115.

Adding Comments to QueriesComments may span multiple lines but may not be nested inside one another. Comments are stored in the history database as part of the query.

To add comments to your queries

✔ For single-line comments, precede the comment with 2 dashes (--).

✔ For multiple-line comments, precede the comment with a forward slash and asterisk (/*), and follow the comment with an asterisk and forward slash (*/).

To temporarily comment out some of your SQL query

1 Highlight the code you want to comment out.

2 On the Query Window toolbar, click or press Ctrl-D to comment out the highlighted text.

Note: If you select a comment, clicking on the icon removes the comment delimiter from around the selected comment, restoring the contents as part of the query.

82 Teradata SQL Assistant for Microsoft Windows User Guide

Page 83: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 2: The Query WindowWorking With SQL Text in the Query Window

Highlighting a block of TextThis function can only be used when the cursor is positioned at the start or end character or keyword of a logical block. An example is at an open or close paren or at a start/end comment symbol. Use the following procedure to highlight a block of text.

To highlight a block of Text

✔ Click to select a logical block of text.

Showing WhitespaceUse to following procedure to show the whitespace in the query using the Show Whitespace button on the query toolbar.

When whitespace appears, space characters are shown as a single dot and tab characters appear as two chevrons.

To show whitespace in a query

✔ Click to show the whitespace in a query. Click again to turn off whitespace.

Converting Tabs to SpacesThe Tabs-to-Spaces button converts tabs already in a query to spaces. The following procedure explains how to use this feature.

To convert tabs into spaces

✔ Click button on the Query toolbar.

Indenting Lines in a QueryUse the Indent buttons on the Query Toolbar to indent lines in a query. The following steps explain how.

To indent lines in a query

1 Place the curser in the line to be indented or highlight multiple lines.

2 Click to indent the line(s) to the right.

3 Click to indent the line(s) to the left.

Note: If multiple lines are selected, you can use the Tab key to perform step 2. You can also use the Shift-Tab key to perform step 3.

Teradata SQL Assistant for Microsoft Windows User Guide 83

Page 84: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 2: The Query WindowWorking With SQL Text in the Query Window

Using the Right-to-Left Editor for QueriesThe Right-to-Left edit box allows you to create queries using right-to-left languages such as Hebrew or Arabic. The following steps explain how.

To use the right-to-left editor

1 From the toolbar, click Edit> Right-to-Left . The Right-to-Left Editor window opens.

2 Enter the query and click OK. The query appears in the Query window.

Deleting Blank Lines from a QueryTo delete blank lines from a query, use the Delete blank Lines button on the query toolbar. The follow steps explain how.

To delete black space in a query

1 Highlight the range of lines from which you want to remove blank lines.

2 Click the button.

Note: To remove all blank lines in the query, use Ctrl+A to select the entire query before clicking the button.

Finding a Text String in the Query WindowYou can find specific text strings in the Query Window using the Find dialog box.

To find text in the Query Window

1 With the Query Window active, do one of the following:

• From the Toolbar, click .

• Select Edit > Find from the menu bar.

• Press Ctrl+F.

2 Enter the desired text string in the What field. If you want to build a regular expression, you can access predefined strings by clicking the solid arrow to the right of this field and selecting the expression you want inserted.

3 Choose from the following options:

• Whole word only - finds text only where the whole word matches the search string

• Match case - finds text that only matches the case of the search string

• Regular Expression - finds regular expressions.

4 Specify the search direction by selecting Direction up or down.

5 Click Find Next to locate the string.

84 Teradata SQL Assistant for Microsoft Windows User Guide

Page 85: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 2: The Query WindowDisplaying an Explain Plan of a Query

To locate consecutive strings, click Find Next or press F3.

6 Click Mark All if you want to place a bookmark on each line containing the search string.

7 Click Cancel to close the dialog box.

Replacing a Text String in the Query WindowReplace any text string in the Query Window with another by using the following procedure.

To replace text in the Query Window

1 With the Query Window active, do one of the following:

• From the Query Window Toolbar, click .

• Select Edit > Replace from the menu bar.

• Press Ctrl+H.

2 Enter the desired text string in the What field. If you want to build a regular expression, you can access predefined strings by clicking the solid arrow to the right of this field and selecting the expression you want inserted.

3 Enter the desired replacement text string in the Replace with field.

4 Choose from the following:

• Whole word only - finds text only where the whole word matches the search string

• Match case - finds text that only matches the case of the search string

• Regular Expression - finds regular expressions.

• Preserve Case - carries the case of the initial string through to the changed string.

5 Choose from the following:

• Select Replace in Selection if you want to narrow the Replace action to the selected text, or select Entire Query to change the strings regardless of what text is selected.

• Click Find Next to locate the string.

• Click Replace to replace the selected string, or the next string matching the find criteria.

• Click Replace All to replace all strings matching the find criteria.

6 Click Cancel to close the dialog box.

Displaying an Explain Plan of a Query

This section provides information about displaying EXPLAIN plans of queries:

• Displaying a Visual EXPLAIN Plan

• Displaying a Textual EXPLAIN Plan

Teradata SQL Assistant for Microsoft Windows User Guide 85

Page 86: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 2: The Query WindowDisplaying an Explain Plan of a Query

Displaying a Visual EXPLAIN PlanYou can display a visual EXPLAIN of a single-statement query currently in the Query Window.

This menu command appears if:

• You have the Teradata Visual Explain application (version 3.0 or later) installed on your PC, and

• If you are connected to a Teradata Database

To display a Visual EXPLAIN plan

1 Select Tools > Visual Explain.

2 In the Visual Explain dialog box, enter the name of the Query Capture Database (QCD) and click OK.

Note: It takes a few moments for the Insert Explain statement to execute, and you cannot continue using SQL Assistant until Visual Explain is launched.

To set up a QCD, refer to the Teradata Visual Explain User Guide.

Displaying a Textual EXPLAIN PlanYou can run an Explain function on the SQL statements in the Query window and display the results in the Answerset window. Teradata SQL Assistant displays the steps that would be executed if you were to actually run the query.

To issue a Textual EXPLAIN for a whole query

✔ Do one of the following:

• Select Tools>Explain.

• Press F6.

The explanation appears in the Answerset window.

ExampleThe explanation below is returned for the following statement:

sel * from dbc.sessioninfo

86 Teradata SQL Assistant for Microsoft Windows User Guide

Page 87: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 2: The Query WindowQuery Builder Overview

To issue a Textual EXPLAIN for part of a query

1 Select Tools > Options.

2 Select the Query tab

3 Select the option Submit only the selected Query text, when highlighted.

4 Highlight part of a query that you want explained (the highlighted portion must be a valid SQL statement).

5 Select Tools > Explain.

The query explanation appears in the Answerset window.

Query Builder Overview

Query Builder is a tool that helps you create statements to add to the Query window.

This section contains information on the following:

• SQL Statements

• Procedure Builder

• <User Defined>

• Using Query Builder

• Supported Databases for Query Builder

• Creating Custom SQL Sets

SQL StatementsWhen you choose the SQL Statements option, the statement list in the left pane shows each of the statement types available on the current data source. The syntax file name matches the database type with a file type of .syn. For example, the Teradata syntax file is Teradata.syn.

SQL examples are quick and easy to use. In many cases, using these statements eliminates the need for the database manual. Syntax is provided in working form, not syntax notation, for ease of use. Choose a statement that best fits your requirements and insert it into the Query Window. You can then tailor it to your needs.

Teradata SQL Assistant for Microsoft Windows User Guide 87

Page 88: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 2: The Query WindowQuery Builder Overview

These syntax examples reflect the SQL syntax of the data source you are currently connected to. If you are not connected to any server, syntax is based on the server you were most recently connected to. If you have not connected to any server during the current Teradata SQL Assistant session, you get Teradata syntax by default.

Procedure BuilderProcedure Builder provides a list of valid statements used to build the logic of a stored procedure. Vendor specific syntax is available for many databases. If specific syntax is not available for or does not apply to the database, a message indicates the problem.

<User Defined>Query Builder allows you to create your own SQL Sets through the <User Defined> option. Each SQL Set must be given a name that appears in the dropdown list. When selected, the SQL Examples, snippits, or queries contained in that SQL Set appear in the List below. Each SQL Set is saved as a *.qbs file. This allows a DBA, or user, to create SQL Sets and easily distribute them to other users.

For information on creating a custom file, see “Creating Custom SQL Sets” on page 90.

Using Query Builder Using Query Builder is an easy and convenient to build SQL statements in the Query window. The following steps explain how.

To use Query Builder

1 Open Query Builder by doing one of the following:

• Press F2.

• Select Help > Query Builder.

• Right-click in the Query Window and select Query Builder from the shortcut menu.

2 From the drop-down list, choose a statement type. See “Table 14: Query Builder Statements” on page 89 for a description of the statement types.

3 Do one of the following to move the statement to the Query window:

• Double-click the statement in the left pane.

• Right-click the statement for the following options:

• Insert into query - inserts the statement the Query window

• Replace query - replaces the statement in the Query window

• Copy to clipboard - copies the statement to the Clipboard

• Drag and drop the statement into the Query window (insert it where you like).

4 Build statements as desired. To learn more about building custom SQL Sets, see also “Creating Custom SQL Sets” on page 90.

88 Teradata SQL Assistant for Microsoft Windows User Guide

Page 89: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 2: The Query WindowQuery Builder Overview

Note: The state of the Query Builder window (its size, and which list you are viewing) is saved so that future uses of the Query Builder window start in the same state that it was last used in.

Supported Databases for Query BuilderSyntax examples are currently provided for the following types of databases:

Table 14: Query Builder Statements

Option Description

SQL Statements

When you choose the SQL Statements option, the statement list in the left pane shows each of the statement types available on the current data source. When you select a statement in the list, an example of that statement appears in the area to the right.

If you are not connected to any server, syntax is based on the server you were most recently connected to. If you are not connected to any server during the current Teradata SQL Assistant session, you receive the default Teradata syntax.

You can customize the statement list or the examples using the tool buttons to the right of this dropdown list.

When connected to a database, you can display the full syntax for the selected statement by doing one of the following:

• Pressing F5

• Right-clicking the Statement list item and selecting Show Syntax from the popup menu

Procedure Builder

Select a stored procedure statement from the list in the left pane to display an example of its syntax in the right pane.

When you choose the Procedure Builder option, the left pane shows a list of statements that are valid only when used in a CREATE or REPLACE procedure statement.

<User Defined>

Additional user (or DBA) defined entries may appear after the above items. Each SQL Set must be given a name that appears in the dropdown list. When selected, the SQL Examples, snippits, or queries contained in that SQL Set appear in the List below. Each SQL Set is saved as a *.qbs file. This allows a DBA, or user, to create SQL Sets and easily distribute them to other users.

For additional information, see also “Creating Custom SQL Sets” on page 90.

Teradata SQL Assistant for Microsoft Windows User Guide 89

Page 90: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 2: The Query WindowQuery Builder Overview

• Teradata

• DB2

• Informix

• Microsoft Access

• Microsoft SQL Server

• MySQL

• Oracle

• Sybase

• HP Neoview

• Ingress

• PostgresSQL

Creating Custom SQL Sets Query Builder lets you create custom SQL Sets. This section explains how.

To create a custom SQL Sets

1 Open Query Builder, Help> Query Builder.

2 Click the New SQL Set button . In the dialog box that appears, enter a name for this new SQL Set and click OK. The new name appears in the drop down box.

3 Click the Add SQL button . In the dialog box, enter a name for the new Example, Query, or Snippit, and click OK. Then in the right pane, enter the SQL for the Example, Query, or Snippit.

4 Click the Save button to save the SQL set.

All SQL sets created and saved appear on the drop down menu. The following table explains each icon in Query Builder.

Table 15: Query Builder Icon Descriptions and Right-Click Options

Icon or menu Description

Click the New SQL Set (Ctrl+N) icon to create a new list of statements. Enter the set name in the dialog box that appears. This name then appears in the drop down list.

Click the Save SQL Set (Ctrl+S) icon to save changes to the current SQL set.

Delete SQL Set (Ctrl+D)

Deletes the current SQL set. Confirm your deletion request when prompted.

90 Teradata SQL Assistant for Microsoft Windows User Guide

Page 91: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 2: The Query WindowScheduling Queries for Later Execution

Scheduling Queries for Later Execution

You can schedule a query that appears in the Query Window to run at a later time using Teradata Query Scheduler.

Requests issued by Teradata SQL Assistant that are restricted by Teradata Workload Management at the current time can be scheduled for later execution, subject to any other scheduled request limitations.

Related Topics• Before Scheduling Queries

• Scheduling Queries for Later Execution

Before Scheduling QueriesFor this feature to be available, you must install the Teradata Query Scheduler client software on your PC.

For more information, see the Teradata Tools and Utilities Installation Guide for Microsoft Windows.

Click the Add SQL (Insert) icon to add a new item to the list in the current SQL Set.

This option is also available by right-clicking a statement.

Click the Delete SQL icon to delete the current list item from the current SQL Set.

This option is also available by right-clicking a statement.

Insert into query (Ctrl+I)

Inserts the statement into the active Query window.

Replace query (Ctrl+R)

Inserts the selected statement in the active Query window by replacing the existing statement.

Copy to clipboard (Ctrl+C)

Copies the selected statement to the clipboard.

Show Syntax Displays the full syntax of the selected statement. This menu only appears when you are connected to a Teradata Database and have selected the SQL Statements item from the dropdown list.

Rename SQL (Ctrl+H)

Changes the name of the selected statement.

Table 15: Query Builder Icon Descriptions and Right-Click Options (continued)

Icon or menu Description

Teradata SQL Assistant for Microsoft Windows User Guide 91

Page 92: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 2: The Query WindowFormatting a Query

Scheduling Queries for Later Execution

To schedule queries for later execution

1 Select Tools > Schedule.

Teradata Query Scheduler launches and the Submit Scheduled Request dialog box opens.

2 Schedule and submit your query.

For more information, see the Teradata Query Scheduler User Guide (B035-2512).

Formatting a Query

The query formatting feature adds line breaks and indentation before certain keywords, making SQL that comes from automatic code generators or other sources more readable.

To format a query

1 Ensure a statement exists in the Query Window.

2 Do one of the following:

• From the Toolbar, click .

• Right-click in the Query Window, then click Format Query

• Press Ctrl+Q

• Select Edit > Format Query

Note: Some keywords cause a line break and possibly cause the new line to be indented. If a keyword is found to already be the first word on a line and it is already prefixed by a tab character, its indentation level does not change.

Related Topics• Indentation

• Language Definition Files

IndentationWhen you press the Enter key, the new line may automatically indent to the same level as the line above. This is controlled by the Indent new lines like previous option on the Code Editor tab of the Options screen.

If you highlight one or more lines in the query and press the Tab key, those lines are indented one level. If you press Shift+Tab, the highlighted lines are unindented by one level.

This indentation of lines only applies if the selected text includes a line feed character. For example, you must either select at least part of two lines or if selecting only one line, the cursor must be at the beginning of the next line.

92 Teradata SQL Assistant for Microsoft Windows User Guide

Page 93: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 2: The Query WindowFormatting a Query

Note: This is always the case when you use the margin to select a line.

If no line end is included in the selected text, or no text is selected, a tab character is simply inserted.

Language Definition FilesSyntax highlighting is based on language definition files (*.lng). These files are automatically installed when you install or upgrade Teradata SQL Assistant and are located in:c:\Documents and Settings\<username>\Application Data\Teradata\SQL Assistant.

There is a corresponding language file for each database type, and the file name uses the database type reported by ODBC. The appropriate language file is loaded when you connect to a database. If you are not connected to a database, Teradata SQL Assistant loads the previously used language file. (The very first time Teradata SQL Assistant is started, it uses the Teradata language file.)

The BASE language file contains the most commonly used definitions found in most SQL languages. This file is the default that is used if you connect to a database type that Teradata SQL Assistant does not recognize. If you plan to work with an unknown database frequently, you can make a copy of the BASE file and save it with an appropriate name to match this unknown database. You may then modify it to match the syntax and keywords used by that language.

In addition to the vendor specific files, there is an ANSI language file that defines the ANSI 2003 SQL language. Select View > ANSI SQL if you want to switch the syntax highlighting to ANSI mode.

The language files generally define the complete language (exceptions are MySQL and Sybase). A DBA can, however, modify the files to suit the site requirements.

The most useful changes to language files would be:

• Adding a keyword that is not defined in the file

• Matching an optional database setting. (For example, some databases have a switch to define the use of double quotes. If the language file says that these double quotes define “Quoted Names”, but you have the option set to allow them to act as string delimeters, you could modify the file accordingly.)

• Preventing users from submitting certain types of statements. Teradata SQL Assistant declares a statement invalid if the primary keyword (the first keyword in the statement) is not found in the “SpanKeywords” or “KeywordsMain” lists. (For example, you can prevent users from executing a DROP statement by moving the DROP keyword from the “KeywordsMain” list to the “KeywordsNL” list.)

Note: Any user can however reverse the changes made to these files, so this can not be used as a security feature.

Teradata SQL Assistant for Microsoft Windows User Guide 93

Page 94: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 2: The Query WindowImporting Data

Importing Data

This section provides information about importing data in queries:

• Before You Begin

• Importing Data from a File

• Exiting from Import Mode

• Types of Import Operations

• Import Rules

• Defining the Null Value for an Import Operation

• Generating Multiple Reports From a Single Query

Before You BeginThe data values required in a query are normally entered as part of the query. The import mode allows you to enter a query containing one or more parameter markers. The data to be used in place of these parameter markers is read from a delimited text file. The query is submitted one time for every record in this input file (the entire query is submitted as a single request).

What types of statements you can issueYou may issue any SQL, Data Manipulation Language (DML) or Data Definition Language (DDL) statement containing one or more placeholders. The statement is executed one time for each record in the supplied import file. The placeholders are replaced with data values in the corresponding record of the file.

Note: DML usually refers to INSERT, UPDATE, or DELETE statements. DDL statement usually refers to CREATE, DROP, ALTER, SHOW, HELP, etc., statements.

What type of files you can importThe import file can be any delimited text file containing the correct number of data values in each record. You can create such a file from a query, using a text editor, or by saving spreadsheet data in a delimited text format.

Skipping the First Line (Header) of Imported filesIf the file you are importing contains headers, you can choose to skip the header record by doing the following.

To skip the header record of an imported file

1 Select Tools > Options.

2 Select the Import tab.

3 Select the option Ignore the first record in the file (Skip Header).

94 Teradata SQL Assistant for Microsoft Windows User Guide

Page 95: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 2: The Query WindowImporting Data

Importing Data from a File

To import data from a file

1 Before running a query, set the import mode by selecting File > Import Data.

2 Enter a statement in the Query window.

3 Execute the statement by clicking on the Toolbar.

4 When the Teradata SQL Assistant Import File dialog box appears, select a file to import and click Open.

Exiting from Import ModeNote: The import mode remains in effect until you turn it off. You can exit from import mode and submit regular queries.

To exit import mode

✔ Select File > Import Data, making sure that the option is cleared.

Types of Import OperationsThere are three types of import operations:

Type 1: Parameterized ImportThis form applies to CALL, EXECUTE, SELECT, INSERT, UPDATE, and DELETE statements only (with Microsoft Access, this form is used for INSERT only.) The parameter markers may only be used in place of data values and must not be enclosed in quotes.

There are four types of parameter markers in this case:

• ? - The data for this parameter is read from the Import file. It is always a character string, and converts to a numeric value if necessary.

• ?? - The data for this parameter is read from the Import file. It should contain a Hexadecimal string which may optionally contain dashes between each byte value. For example: 414B43 or 41-4B-43.

• ?B - The data for this parameter resides in a file that is in the same directory as the Import file. The import file contains only the name of the file to be imported. The contents of the file are loaded as a binary image.

• ?C - The data for this parameter resides in a file that is in the same directory as the import file. The import file contains only the name of the file to be imported. Use this marker to load a text file into a CHAR or CLOB column.

For example:

Insert Into TestTbl Values (?, ?, , 'Const', ??, ?B, ?C)

In the example above:

Teradata SQL Assistant for Microsoft Windows User Guide 95

Page 96: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 2: The Query WindowImporting Data

• The table must have a total of seven columns

• A NULL character is inserted in column 3 for all rows

• The word 'Const' is inserted in column 4 for all rows

• The ?, ??, ?B, ?C characters are the parameter markers

• The import file must have five data values per record

• The 3rd parameter must be a hexadecimal string

• The 4th parameter must be the name of a binary data file in the same directory

• The 5th parameter must be the name of a text file in the same directory

Type 2: Direct SubstitutionThis form applies to all other statements. Parameter markers may be used anywhere in the query. The data values are directly edited into the SQL at the parameter positions. Therefore, some parameter markers may need to be enclosed in quotes.

Create User ? As Perm=0 Password=? Account=’?’

Note: In Direct Substitution, only the “?” parameter is valid.

If an IMPORT statement returns data, the results are written to a file whose name is formed by adding ‘.Log’ to the end of the import file name. If this file already exists, its contents are replaced with new results. A header record containing the first data value from the corresponding import record is written before each set of returned data.

Type 3: BatchThis form applies when the following conditions are met:

• Teradata SQL Assistant is connected through Teradata.NET, not ODBC

• The query consists of a single INSERT, UPDATE, or DELETE statement

• All parameter markers are simple ‘?’ parameters. No LOB or binary parameters

• The Batch size in the Import tab of the Options dialog box is not specified as one

If the Batch size is set to one, the Batch import mode is not used. For larger values, the data provider packs the data for the specified number of rows into a batch (as long as it fits into a 64k parcel), and executes one batch at a time.

In general, the larger the batch size, the better the performance. With larger batch sizes, the trade offs are:

• Data for a single batch must fit into a 64k parcel

• The entire Import file is loaded into memory

• There is little or no progress status from Teradata SQL Assistant during a large batch import

• If a batch import results in an error, the entire batch is rolled back and Teradata SQL Assistant reports which record caused the error

• If multiple records result in errors in a single batch, the indicated record may not be the first problem record in the file

96 Teradata SQL Assistant for Microsoft Windows User Guide

Page 97: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 2: The Query WindowImporting Data

The Silently discard rows that cause constraint violations option on the Import tab of the Options dialog box can be selected if the data is just a sample, or if loss of duplicates or other rows that cause constraint violations are not a problem. If this option is selected, all errors are ignored and Teradata SQL Assistant reports the number of rows that were imported and the number of rows discarded.

Import RulesThe following import rules are important:

• If the option Submit only the selected Query text, when highlighted is selected in the Options dialog box, only the highlighted portion of the query is submitted. For more information, see also “Submitting Part of a Query” on page 75.

• The query may contain multiple statements only if it contains Teradata INSERT, UPDATE, or DELETE statements. For other databases, or statements, it is limited to a single SQL statement.

• The import file must be a delimited text file containing data values that are separated from each other with a delimiter character. To set the delimiter character, see “Setting Export/Import Options” on page 129.

• The number of data values on each record must be the same as the number of parameter markers in the SQL query.

• The maximum number of parameters in a query is database dependent. For Teradata V2R5, it is 2,048.

• The data values must be enclosed within quotes unless the Export option, Enclose Exported/Imported Column Data in, is set to None. To set this option, see “Setting Export/Import Options” on page 129.

• Data values must not contain the delimiter character unless they are enclosed in quotes. Data values that are enclosed in quotes must not contain the delimiter character as their first character.

• Data values must not contain carriage return (end of line) characters.

• Date, time and timestamp values must be in the following format:

• YYYY-MM-DD

• HH:MM:SS

• YYYY-MM-DD HH:MM:SS

When using an ODBC connection with a Teradata data source, they must be in the format specified for the corresponding column on the CREATE TABLE statement. Either ‘-‘ or ‘/’ may, however, be used as the date separator.

You can create the import file using the export feature of Teradata SQL Assistant. Be sure when importing the file to select the option to skip the first row (header) of the file.

Alternatively, you may create the file using a text editor or by saving a spreadsheet in the appropriate delimited format.

Teradata SQL Assistant for Microsoft Windows User Guide 97

Page 98: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 2: The Query WindowImporting Data

Defining the Null Value for an Import OperationThe default value for this option is ?. This means a question mark character is used to represent a null value resulting from a SELECT statement. This string is also used in an import file to indicate that the corresponding column should be assigned a null value.

Many spreadsheet and database applications can save data in tab delimited format. In most cases, they do not allow you to specify a null character, but simply write nothing to the file. If you want to import data from a file like this, set this field to a zero length string by deleting the contents of the field.

To indicate a null data value in the import file

1 Select Tools > Options.

2 Select the Data Format tab.

3 In the field Display this string for Null data fields, fill in the string desired.

Use the string you have defined for the display of NULL values. The default is a question mark (?). This string, possibly quoted, should be the only thing between the surrounding delimiter characters.

Generating Multiple Reports From a Single QueryYou can generate multiple reports from a single query using SQL Assistant’s import feature. This is often useful for DBAs.

Example - to show the DDL for a list of tables

1 Create an import file (typically a .txt file) that contains a list of tables, one table name per line.

2 Select File > Import Data.

3 Enter the following into the Query Window:

SHOW TABLE ?

4 Click .

This displays a file selection dialog box.

5 Select the file you saved.

The status bar at the bottom of the Query window shows row numbers as they are loaded.

6 To obtain the results of the query, go to the directory in which you saved the import file and open the .log file.

98 Teradata SQL Assistant for Microsoft Windows User Guide

Page 99: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 2: The Query WindowUsing the Query Window Shortcut Menu

Using the Query Window Shortcut Menu

The purpose of the shortcut menu is to access routine query functions or to control its execution. The shortcut menu is specific to the active window. In this case, it provides a quick way for performing tasks specific to the Query Window.

• Displaying the Shortcut Menu

• Functions in the Query Window

Displaying the Shortcut MenuThe following table describes the commands on the default shortcut menu.

To display the shortcut menu

✔ Do one of the following:

• Right click in the Query Window.

• Press Shift-F10.

• Press the Context Menu key on your keyboard.

Table 16: The Query Window Shortcut Menu Commands and Descriptions

Command Description

Execute Submits the query currently in the Query Window. Each statement in the query is submitted separately to the database.

Query Builder Helps you create statements in the Query Window.

Add to Favorites Saves the current query to a list of favorites which can be reused from Query Builder.

Cut Cuts the selected text from the Query Window and places it to the Clipboard.

Copy Copies the selected text from the currently active window to the Clipboard.

Paste Pastes the contents of the Clipboard into the query at the current insertion point.

Find Displays the Find String in Query dialog box, allowing you to search for a particular string in the currently active window. Find highlights the first occurrence of the string.

Repeated use of the Find Next button highlights successive occurrences of the search string.

Find Next Finds the next occurrence of the string that was specified in the previous Find command. If you have not yet issued a Find command, it acts as a Find command

Teradata SQL Assistant for Microsoft Windows User Guide 99

Page 100: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 2: The Query WindowUsing the Query Window Shortcut Menu

Functions in the Query WindowThe Query Window is similar to any Windows-based text editor, allowing for functions such as drag-and-drop editing, cutting, copying, and pasting.

Clipboard SupportClipboard support is provided in the Query Window.

Replace Finds and replaces any, or all, occurrences of a particular string in the Query Window. This command is useful for quickly replacing a string that occurs multiple times in your query. For example, use this command to change the name of a database referenced multiple times within a macro or script.

Format Query Formats a query based on a search for specific keywords.

Set Font Displays a Font dialog box allowing you to change the font used in the current window.

The Font Name and Font Size attribute are saved for future use. Separate values are stored for each type of window.

Select All Selects all the text in the current window. All text is highlighted and future actions apply to the entire window as a whole.

The primary use of this function allows you to copy the query to the Clipboard.

Insert date Inserts today’s date into the query at the current insertion point. If part of the query is selected, this function replaces the selected text with today’s date.

The format of the date is always 'yyyy-mm-dd' enclosed in quotes, or in '#' signs for Microsoft Access..

Audible Notification

Causes the system to beep when the query is complete and all data has been returned to your PC. The beep also occurs if the query times out, the number of rows exceeds the output limit, or the query is canceled.

Minimize on Execution

When selected, automatically minimizes the Teradata SQL Assistant window when a query is being processed.

Prompt for Notes An input dialog box displays whenever you submit a query to enter a note that is stored in the history table along with the query.

Table 16: The Query Window Shortcut Menu Commands and Descriptions (continued)

Command Description

Table 17: Clipboard Support - Edit Commands

Action From the Toolbar From the Menu Shortcut Keys

Cut Click Edit > Cut Ctrl+X

Copy Click Edit > Copy Ctrl+C

100 Teradata SQL Assistant for Microsoft Windows User Guide

Page 101: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 2: The Query WindowUsing the Query Window Shortcut Menu

Paste Click Edit > Paste Ctrl+V

Undo Click Edit > Undo Ctrl+Z

Redo Click Edit > Redo Ctrl+Y

Table 17: Clipboard Support - Edit Commands (continued)

Action From the Toolbar From the Menu Shortcut Keys

Teradata SQL Assistant for Microsoft Windows User Guide 101

Page 102: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 2: The Query WindowUsing the Query Window Shortcut Menu

102 Teradata SQL Assistant for Microsoft Windows User Guide

Page 103: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

CHAPTER 3

The Answerset Window

The purpose of this section is to help you become familiar with the Answerset window and its features and functions. This section contains the following information:

• Introduction to the Answerset Window

• Using the Answerset Window

• Charting Answerset data

• Formatting an Answerset

• Exporting a Resultset

• Understanding Large Object Support

• Using Answerset Shortcut Menus

Introduction to the Answerset Window

The Answerset window contains one or more tabs. Each tab displays either a spreadsheet or textual output that represents the results from an executed statement. You can sort the output in a number of ways and print as bitmaps in spreadsheet format. Individual cells, rows, columns, or blocks of columns may be formatted to change the background and foreground color as well as the font style, name, and size. You can make other modifications such as displaying or hiding gridlines and column headers.

The table may be resized by stretching the Answerset window using standard Windows sizing techniques. Individual columns, groups of columns, rows, or groups of rows may also be sized.

Output rows may be viewed as they are being retrieved from the database.

Following is an example of an Answerset window:

Teradata SQL Assistant for Microsoft Windows User Guide 103

Page 104: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 3: The Answerset WindowUsing the Answerset Window

You can set an option to prevent existing Answerset windows from being automatically closed when you submit a new query. For more information, see “Setting Answerset Options” on page 117.

You can save Answerset output to a file. For more information, see “Saving an Answerset to a File” on page 112.

Using the Answerset Window

This section provides the following information about using the Answerset Window:

• Viewing Your Results

• Adjusting Row Height

• Adjusting Column Width

• Re-arranging Column Order

• Keeping Selected Columns From Scrolling Out of View

• Viewing Long Strings of Text Within Cells

• Closing Answerset Windows Before Submitting a New Query

• Selecting All Answerset Rows

• Merging Cells in the Answerset

• Displaying the SQL That Generated an Answerset

• Hiding Columns/Showing All Columns

• Closing All Answersets

• Hiding Column Headers

• Hiding Row Headers

• Displaying Totals for Numeric Columns

• Displaying Aggregate Values

• Finding a Text String in the Results Grid

• Naming an Answerset Window

• Naming an Answerset Tab

• Deleting an Answerset Tab

• Opening a Saved Answerset

• Saving an Answerset to a File

• Saving as XML

• Copying an Answerset to Notepad

• Printing an Answerset

• Using Print Preview

• Cancelling Print Jobs

• Sorting an Answerset

• Filtering the Answerset

104 Teradata SQL Assistant for Microsoft Windows User Guide

Page 105: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 3: The Answerset WindowUsing the Answerset Window

• Grouping the Answerset

• Setting Answerset Options

• Setting Data Format Options

• Changing the Font for the Entire Window

• Zooming the Answerset Window

Viewing Your ResultsUse the Page Up, Page Down, Home and End keys as well as scroll bars to scroll through the results. Output rows may be viewed as they are being retrieved from the database.

Adjusting Row Height

To adjust the row height

1 Move the mouse pointer to the line directly under the row header. When correctly positioned, the mouse pointer changes to a two-headed vertical arrow.

2 Drag the two-headed arrow up or down to size the row and then release the mouse button.

To change multiple rows, highlight all the rows by placing the mouse pointer on the row number and dragging. Then follow steps 1 and 2, above.

Adjusting Column Width

To adjust the column width

1 Move the pointer onto the column separator directly to the right of the column heading. The pointer changes to a two-headed horizontal arrow.

2 Drag the column left or right to size the column and then release the mouse button.

To change multiple columns, highlight all the columns by placing the mouse pointer on the column header and dragging. Then follow steps 1 and 2, above.

Note: If you want to reset the width to fit the widest data value in that column, double click the right hand edge of the column header.

Re-arranging Column OrderIn “Move Columns” mode, you can re-arrange the columns by clicking on a column header and dragging it to the desired position.

Note: While in this mode, columns can no longer be selected by clicking on their column headers.

Teradata SQL Assistant for Microsoft Windows User Guide 105

Page 106: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 3: The Answerset WindowUsing the Answerset Window

To turn on Move Columns mode

✔ Do one of the following:

• Right-click in the Answerset window, select Move Columns.

• Click on the Answerset Toolbar.

To switch off Move Columns mode, repeat this procedure.

Keeping Selected Columns From Scrolling Out of ViewFreezing columns prevents them from being scrolled off the screen when you scroll a wide Answerset to the right.

To freeze columns in the Answerset

1 In the Answerset window, select the column you want to freeze.

Note: The selected column and all columns to the left of the selected column freeze.

2 Do one of the following:

• Right-click in the Answerset window and select Freeze Columns.

• Click on the Answerset Toolbar.

The columns remain frozen until you repeat Step 2 a second time to unfreeze them.

Viewing Long Strings of Text Within CellsYou can select an option that wraps the text onto multiple lines if it does not fit entirely within the cell or column on one line.

To wrap text onto multiple lines an Answerset

1 In the Answerset window, select the cells or columns you want to wrap.

2 Do one of the following:

• Right-click in the Answerset window and select Wrap Text.

• Click on the Answerset Toolbar.

The cells remain wrapped until you repeat Step 2 a second time to unwrap them.

Note: Wrap Text is hierarchical. If you wrap individual cells they remain wrapped even if you wrap/unwrap the column that contains those cells.

Closing Answerset Windows Before Submitting a New QueryYou can prevent an Answerset from being automatically closed, still allowing you to close the window manually.

106 Teradata SQL Assistant for Microsoft Windows User Guide

Page 107: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 3: The Answerset WindowUsing the Answerset Window

To prevent an Answerset from being automatically closed

✔ Do one of the following:

• Right-click in the Answerset window and select Do Not Close

• Click on the Answerset Toolbar

Selecting All Answerset RowsYou can select all rows in the Answerset window.

To select all Answerset rows

✔ Do one of the following in the Answerset window:

• Press Ctrl+A.

• Click the top/left header cell (at the intersection of the Column and Row headers.).

All rows in the Answerset window are selected.

Merging Cells in the AnswersetUse this option to merge the cells in a column.

You can select one or more columns. (If you select only one or more cells, the merge applies to the entire column(s) of the cells selected)

If consecutive rows contain the same data (within any of the selected columns), those cells appear as a single 'merged' cell.

If you have previously applied 'Merge Cells' to a column, applying it again restores the column(s) to an un-merged state.

This option merges only cells that contain the same data. Cells with other data in the same column do not merge. If there are no consecutive cells with the same data, nothing happens. This is not an error.

To merge cells in the Answerset

1 Select the column that contains cells you want to merge.

2 Do one of the following:

• Right-click the selected column and select Merge Cells.

• Click on the Answerset Toolbar.

Displaying the SQL That Generated an AnswersetYou can display the SQL statement that generated an Answerset.

Teradata SQL Assistant for Microsoft Windows User Guide 107

Page 108: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 3: The Answerset WindowUsing the Answerset Window

To display the SQL that generated an Answerset

✔ Do one of the following:

• Right-click in the Answerset window and select Display SQL / Answer

• Make sure the Answerset window is active, then click on the Answerset Toolbar to toggle between the Answerset and the SQL.

The SQL statement that generated the data replaces the results in this Answerset.

Hiding Columns/Showing All ColumnsYou can hide columns or show all columns in the Anwserset using the following steps.

To hide column(s) or show all columns

✔ Do one of the following.:

• In the Answerset, right-click the columns to hide and select Hide Columns.

• To show all columns, right-click in the Answerset and select Show All Columns.

Closing All Answersets

To close all Answersets

✔ Select File > Close all Answersets.

Hiding Column Headers

To hide column headers

1 In the Answerset window, place your cursor into any cell in any column.

2 Do one of the following:

• Click on the Answerset Toolbar.

• Right-click in the Answerset window and select Column Headers.

The columns remain hidden until you click again to display them. This preference applies only to the current tab of the current Answerset window.

Hiding Row Headers

To hide row headers

1 In the Answerset window, place your cursor into any cell in any column.

2 Do one of the following:

108 Teradata SQL Assistant for Microsoft Windows User Guide

Page 109: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 3: The Answerset WindowUsing the Answerset Window

• Click on the Answerset Toolbar

• Right-click in the Answerset window and click Row Headers.

The rows remain hidden until you click again to display them. This preference applies only to the current tab of the current Answerset window.

Displaying Totals for Numeric Columns

To display totals at the bottom for numeric columns

1 In the Answerset window, place your cursor into any cell in any column.

2 Do one of the following:

• Right-click to bring up the Shortcut menu and click Add Totals.

• Click on the Answerset Toolbar.

The totals display for all numeric columns.

The totals remain after the Answerset has been sorted. Totals do not appear in future Answerset windows unless Add Totals is activated again.

Note: The SUM function uses Floating Point values, so totals are only accurate to 15 total digits.

To format columns to display commas, see “Displaying Commas to Mark Thousand Separators” on page 126. To format columns to display decimal places, see “Displaying Decimal Places” on page 126.

Displaying Aggregate ValuesTeradata SQL Assistant allows you to quickly calculate aggregate values for selected portions of the Answerset window.

To display aggregate values

1 Highlight the cells you want to aggregate.

2 Release the mouse button. The Sum, Count, Average and Standard Deviation appear on the status bar.

Note: The Aggregate function uses Floating Point values, so totals are only accurate to 15 total digits.

You may select a row, multiple rows, a column, multiple columns, or any block of cells. Nonnumeric cells included within your selection are ignored.

Finding a Text String in the Results GridYou can find a specific text string in the results grid.

Teradata SQL Assistant for Microsoft Windows User Guide 109

Page 110: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 3: The Answerset WindowUsing the Answerset Window

To find text in the results grid

1 With the grid window active, select Edit > Find. The Find dialog box displays.

2 Complete the following options:

Table 18: Find Dialog Box

Option Description

Find What Enter the desired text string, or select an existing text string .

Match Case Select this checkbox to find text that matches the case of the search string.

Search current column only

Clear this checkbox to search the entire spreadsheet. If multiple cells are selected, the current cell is marked with a bold outline.

The default is selected, but the new setting is retained if it is changed.

Note: Searches are faster when they are limited to a single column.

Use wildcard characters (* and ?)

Select this checkbox to treat any question mark symbol (?) and asterisk symbol (*) in the search string as a “wildcard” character.

The question mark represents any single character. The asterisk represents any string of zero or more characters.

Find Next Click to search for the next occurrence of the search string within the current grid. The search starts at the current cell position in the grid.

Find All Click to find all occurrences of the search string and display them in a listbox. Clicking an item in the list moves the selection in Answerset to the corresponding cell. The cell scrolls into view if necessary.

110 Teradata SQL Assistant for Microsoft Windows User Guide

Page 111: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 3: The Answerset WindowUsing the Answerset Window

Naming an Answerset WindowInstead of having Teradata SQL Assistant title the saved Answersets for you, you can name the returned Answersets.

To name an Answerset window

1 Do one of the following:

• Select Window > Set Title.

• Press F12.

2 In the Set Title dialog box, enter a new title for this Answerset.

Naming an Answerset TabWhen Answersets appear in tabs, you can set the name for each individual tab.

To name an Answerset tab

1 Right-click on the Answerset tab and select Rename.

2 Enter a new name for this Answerset tab.

Deleting an Answerset TabWhen Answersets appear in tabs, you can delete individual tabs and their contents.

To delete an Answerset tab

✔ Right-click on the tab and select Delete.

Opening a Saved Answerset

To open a saved Answerset

1 Select File > Open Answerset.

2 Select the file you want to load into a new Answerset window. You can only load tab-delimited, delimited text, or Microsoft Excel files.

3 Click Yes or No when asked whether the first line of the file contains column headers.

Note: To set the delimiter between columns for a Delimited Text file, see “Setting Export/Import Options” on page 129.

Teradata SQL Assistant for Microsoft Windows User Guide 111

Page 112: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 3: The Answerset WindowUsing the Answerset Window

Saving an Answerset to a File

To save an Answerset to a file

1 Click the Answerset window to make it the active window.

2 Do one of the following:

• From the Toolbar, click .

• Select File > Save Answerset As.

• Press Ctrl+S.

3 In the Save Answerset dialog box, enter a file name and choose a format type. See “File Format Types”.

4 Choose a location and click Save.

File Format TypesYou can save an Answerset in the following formats:

Table 19: Answerset File Format Types

File Type Description

Tab delimited [ANSI]

The data is saved in a tab-delimited file using the current code page.

Any special formatting applied to the Answerset is not saved, but may be read into a spreadsheet or a text editor for formatting. If a block of cells is selected, only that block is saved. If no part of the spreadsheet is selected, the entire Answerset is saved. The column headings are saved only if they are visible on the screen.

Tab Delimited [Unicode]

The data is saved in a tab-delimited file using Unicode.

Any special formatting applied to the Answerset is not saved, but may be read into a spreadsheet or a text editor for formatting. If a block of cells is selected, only that block is saved. If no part of the spreadsheet is selected, the entire Answerset is saved. The column headings are saved only if they are visible on the screen.

Tab delimited [UTF-8]

The data is saved in a tab-delimited file using UTF-8.

Any special formatting applied to the Answerset is not saved, but may be read into a spreadsheet or a text editor for formatting. If a block of cells is selected, only that block is saved. If no part of the spreadsheet is selected, the entire Answerset is saved. The column headings are saved only if they are visible on the screen.

Delimited Text [ANSI]

The data is saved is a delimited text file using ANSI. To set the use of quotes or to set the delimiter between columns, see “Setting Export/Import Options” on page 129.

If a block of cells is selected, only that block is saved. If no part of the spreadsheet is selected, the entire Answerset is saved. The column headings are saved only if they are visible on the screen.

112 Teradata SQL Assistant for Microsoft Windows User Guide

Page 113: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 3: The Answerset WindowUsing the Answerset Window

Note: Hidden columns are not saved if you save as HTML.

Note: When saving an answerset tab, spreadsheet data is saved using one of the file types from the table above, while Text data is saved using one of the file types described under “To save a query” on page 80.

Saving as XMLWhen saving as XML, the domain name hierarchy is Answerset<n>, DataRow, <ColumnNames>. For example:

Delimited Text [Unicode]

The data is saved is a delimited text file using Unicode.

If a block of cells is selected, only that block is saved. If no part of the spreadsheet is selected, the entire Answerset is saved. The column headings are saved only if they are visible on the screen.

Delimited Text [UTF-8]

The data is saved is a delimited text file using UTF-8.

If a block of cells is selected, only that block is saved. If no part of the spreadsheet is selected, the entire Answerset is saved. The column headings are saved only if they are visible on the screen.

Microsoft Excel 2003

The data is saved to an Excel 2003 workbook. If there are multiple tabs in the Answerset window, you are asked whether you want to save all tabs to a single ExcelWorkbook.

Any special formatting you have applied to the Answerset is retained. The entire Answerset is saved. Column and row headers are saved if they are currently visible.

Microsoft Excel 2007

The data is saved to an Excel 2007 workbook. If there are multiple tabs in the Answerset window you are asked whether you want to save all tabs to a single ExcelWorkbook

Any special formatting you have applied to the Answerset is retained. The entire Answerset is saved. Column and row headers are saved if they are currently visible.

PDF Document [*.pdf]

The data is saved as a PDF file.

Any special formatting you have applied to the Answerset is retained. If a block of cells is selected, only that block is saved. If no part of the spreadsheet is selected, the entire Answerset is saved.

Web Page [*htm]

The data is saved as a table in HTML.

Any special formatting you have applied to the Answerset is retained. If a block of cells is selected, only that block is saved. If no part of the spreadsheet is selected, the entire Answerset is saved.

XML Document The data is saved as an XML document.

No special formatting is retained. If a block of cells is selected, only that block is saved. If no part of the spreadsheet is selected, the entire Answerset is saved. See “Saving as XML” on page 113.

Table 19: Answerset File Format Types (continued)

File Type Description

Teradata SQL Assistant for Microsoft Windows User Guide 113

Page 114: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 3: The Answerset WindowUsing the Answerset Window

<?xml version="1.0" ?><Answerset1>

<DataRow><FirstName>John </FirstName><LastName>Smith </LastName><Number>201-555-2182</Number>

</DataRow>

Copying an Answerset to Notepad

To copy a whole Answerset to Notepad

1 Make the Answerset active.

2 Select File > Copy to Notepad.

The contents of the whole Answerset is copied to Notepad.

Note: If you select a subset of cells within the Answerset, only the selected cells are copied to notepad.

Printing an Answerset

To print an Answerset

1 Click the Answerset window to make it the active window.

2 Do one of the following:

• From the Toolbar, click .

• Select File > Print Answerset.

• Press Ctrl+P.

3 The standard Windows Print dialog box appears. Printers are configured through this Print dialog box. To print the entire Answerset, under Print Range, select All.

To print a partial section of the Answerset, go to the Answerset window and highlight the cells, columns, or rows you want to print. Under Print Range, select Selection.

Using Print PreviewThe Print Preview dialog box allows you to preview Answerset or History window spreadsheet data before printing. Print preview is only available from the Answerset window and the History window. These two windows print data in the form of a spreadsheet. When printing the Query window or a Text style Answerset window, Print Preview is not available.

To use the Print Preview window

✔ Do one of the following:

114 Teradata SQL Assistant for Microsoft Windows User Guide

Page 115: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 3: The Answerset WindowUsing the Answerset Window

• Select Print Preview under File from the Toolbar.

• To view one or more pages at a time, use the page icon .

• Use the Zoom icon to change the view size.

• To print, click the Print icon .

• View a different page by using the select page field .

Cancelling Print JobsPrint jobs may be canceled through the Windows Print Manager.

To cancel a print job

1 Go to Start, choose Settings, click Printers.

2 Double-click your printer.

3 From the Document menu, choose Cancel.

Sorting an AnswersetThere are two ways to sort an Answerset: quick sort or full sort.

To sort an Answerset using quick sort

✔ Click the sort icon at the top of any column, to sort the data by that column only.

After sorting, the icon indicates the direction of the sort.

The output from certain statements, such as EXPLAIN, cannot be sorted this way.

To sort an Answerset using full sort

Full sort allows sorting by data in multiple columns:

1 Do one of the following:

• From the Toolbar, click .

• Right-click in the Answerset window, then select Sort.

• Select Edit > Sort.

In the Sort Answerset dialog box, all columns in the active window are presented in the Available Columns list box.

2 Select the column name in the Available Columns list box, or use the up or down arrow keys to highlight the column name and press Enter or click the Add button.

This moves the column name to the Sort keys list box.

By default, the sort direction for this new sort column is ascending.

If you click a column in the Sort Keys list box, or select the item using the arrow keys or mouse and press Enter, it reverses to descending sort order.

Teradata SQL Assistant for Microsoft Windows User Guide 115

Page 116: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 3: The Answerset WindowUsing the Answerset Window

3 To remove a sort column from the list, double-click the column name, or select it and press the Delete key or click the Remove button. You may also remove all columns from the Sort Keys list by pressing the Clear button.

4 After you select the columns by which you want to sort and the direction in which you want to sort, click Sort.

Filtering the AnswersetFilter the Answerset by clicking the filter icon on the Answerset column header. A drop down list opens containing all the values in the column. When you click on an item in the list, the rows are filtered to display only those rows containing the selected value in the column. You can also filter by multiple columns, with each filter acting on the currently displayed rows only.

To return to a display of all rows, click the filter icon and select (All rows).

To filter the Answerset

1 Click the Filter icon.

2 Select the column value to filter on. The column is filtered for that value.

3 Click the Filter icon and select All rows to unfilter the column.

Caution: Filtering a large spreadsheet by a unique column may be a slow process. Use Find instead.

Grouping the AnswersetTeradata SQL Assistant can display data rows in the Answerset window in a grouped, sorted order. To use grouping, click on the Allow Grouping tool button.

To group data columns in the Answerset window

1 Make sure the Answerset window is active and click the Allow Grouping

button . This displays a Group Bar above the spreadsheet.

2 Drag the column header you want to group by to the Group Bar.

If you group by a single column, each row in that column displays the column name followed by the column value and the number of rows that have this value in parentheses. To open a group, click on the + symbol at the left of the row.

116 Teradata SQL Assistant for Microsoft Windows User Guide

Page 117: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 3: The Answerset WindowUsing the Answerset Window

3 To group by multiple columns, drag the additional column headers to the right of the previous ones on the group bar. They are connected in descending order.

The top level group continues to display the column name and data value, but does not display the number of rows that contain that value. The lower level Group rows display the column number (starting at column zero) followed by the data value for that group. Each header you drag to the Group Bar display a Sort icon to indicate the current sort direction. You may reverse the direction by clicking on this icon.

4 To ungroup the rows, drag the headers back to the spreadsheet header bar, or simply click the Allow Grouping button a second time.

Setting Answerset OptionsUse the following procedure to control the Answerset and the appearance of data in the Answerset by setting options on the Answerset tab of the Options dialog box.

Additional data options that apply to both the Answerset window and to Exported data may be set on the Data Format tab. See “Setting Data Format Options” on page 119.

Teradata SQL Assistant for Microsoft Windows User Guide 117

Page 118: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 3: The Answerset WindowUsing the Answerset Window

To set Answerset options

1 Select Tools > Options.

2 Click the Answerset tab. Table 20 explains each option.

Table 20: Answerset Tab in the Options Dialog Box

Option Description

Display alternate Answerset rows in color

Select this item to display colors for alternate rows in the Answerset. Use the color picker to choose a color. The color choices include a Custom tab, a Web tab and a System tab.

The default is cleared.

Open new Answersets in Move Columns Mode

Selecting this option activates “Move Columns mode” when a new Answerset opens, which allows you to re-arrange the columns by dragging columns to the desired position. The default for Move Columns mode is off.

Display grid lines in future Answerset columns

The default value of this option is selected. Gridlines appear when a new Answerset window is created.

• Right-click in the Answerset window and select Grid Lines.

• On the Answerset Toolbar click .

Display 1000 separators in numeric columns

The default value of this option is selected. This means 1000 separators (commas) appear in numeric columns.

118 Teradata SQL Assistant for Microsoft Windows User Guide

Page 119: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 3: The Answerset WindowUsing the Answerset Window

Setting Data Format OptionsControl the format of data values that are both displayed the Answerset window and Written to an Export file by setting options on the Data Format tab of the Options dialog box.

To set Data Format options

1 Select Tools > Options.

2 Click the Data Format tab. Table 21 explains each option.

Display negative numbers in Red

This option displays negative values in red in the Answer pane. The default value of this option is cleared.

Display Column Titles rather than Column Names

This option allows the Answerset columns to display titles rather than names. The default value of this option is selected. This means the column title is used as the column header when returning data to the Answerset window.

If cleared, column names appear.

Column titles can be defined at the time a table is created, or as part of a SELECT statement. Generally, a column title is more descriptive than the column name itself.

Wrap wide headers across 2 lines if the data is narrow

The default value of this item is selected. This option allows column titles that are wider than the maximum data width in that column to be wrapped across two lines to display narrower columns. If this option is not selected, column titles display on a single line.

Display Float values using scientific notation

The default value of this option is cleared. If selected, Float column data displays in scientific notation. For example, 1.234567e04.

Use default file names for LOB columns

The default value of this option is cleared.

If selected, the file names used for LOB columns are constructed from the column title and a default file type. You are not prompted to enter this information.

Default file type for BLOB columns

This file type is used for BLOB columns when the above option is selected.

Maximum number of answer rows to display

The default value of this option is 2000. This number is the maximum number of answer rows that are retrieved from the database before you are prompted whether you want to continue retrieving further rows.

If you want all remaining rows to be retrieved without further prompts, answer No to the following question:

Cancel at <number> rows in accordance with settings?

When prompted to continue, all remaining rows are retrieved without any further prompts.

Table 20: Answerset Tab in the Options Dialog Box (continued)

Option Description

Teradata SQL Assistant for Microsoft Windows User Guide 119

Page 120: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 3: The Answerset WindowUsing the Answerset Window

Table 21: Data Format Tab in the Options Dialog Box

Option Description

Display dashes between bytes for binary data values

When selected, a dash appears between each byte of the value for ease of reading, for example ‘63-B1-A3-62’.

The default is selected.

Display BigInt and Decimal(16)+ values as strings

Large numeric values are stored as strings for Excel compatibility. When cleared, values with more than 15 digits are rounded when saved to Excel.

The default is cleared

Display this string for Null data values

Enter the string to be displayed in place of Null data fields in the reports and imported/exported files. The default for this setting is “?”.

120 Teradata SQL Assistant for Microsoft Windows User Guide

Page 121: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 3: The Answerset WindowUsing the Answerset Window

Display dates in this format The drop-down list contains pre-defined options to select. The characters d, m, and y to signify the day, month and year components can be added to the list. It also accepts /, -, ',' and space characters can be added as delimiters.

Day formats are specified by repeating characters as follows:

• d - Day number without leading zero

• dd - Day number with leading zero

• ddd - Day name abbreviated

• dddd - Day name in full

Month formats are specified by repeating characters as follows:

• m - Month number without leading zero

• mm - Month number with leading zero

• mmm - Month name abbreviated

• mmmm - Month name in full

Year formats are specified by repeating characters as follows:

• yy - Year, represented with 2 digits

• yyyy - Year, represented with 4 digits

Insertion Characters:

The dash, slash, comma, period and space characters are insertion characters.

For example: dddd, dd mmm yyyy displays Monday, 07 Mar 2008

Wheras d-mm displays 7-03

Note: Lowercase 'm' is automatically changed to uppercase 'M.'

Number of decimal places to display for Float columns

Entering a value between 0 and 9 allows you to specify the number of decimal places initially displayed for all data that originated from a FLOAT column. The default value for this option is 2.

You can change the setting for selected columns. From the shortcut menu, choose Decimal Places.

Handle Binary/Byte columns as BLOBs if size >

Enter a number between 0 and 64000. The default value for this option is 30.

• 0 - All Binary/Byte columns are treated as BLOBs

• 64000 - Binary/Byte columns are never treated as BLOBs

• Other - Binary/Byte columns larger than this value are treated as BLOBs

Each BLOB is returned to a separate file on your PC. Regular Binary/Byte data appears in the grid as a hex string.

Handle Varchar columns as CLOBs if size >

This options allows you to set a size limit after which a Varchar column is handled as a CLOB. The default is 16384.

Table 21: Data Format Tab in the Options Dialog Box (continued)

Option Description

Teradata SQL Assistant for Microsoft Windows User Guide 121

Page 122: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 3: The Answerset WindowCharting Answerset data

Changing the Font for the Entire Window

To change the font for the entire window

1 Do one of the following:

• From the View menu, choose Set Font to bring up the Font dialog box.

• Right-click to bring up the Shortcut menu and click Set Font.

2 Change the font name, style, and size.

Note: The font change applies to the current window and all future Answerset windows.

Zooming the Answerset WindowYou can zoom the contents of a window in and out by using the Ctrl key and mouse wheel.

To zoom the active window

1 Make sure the window is active.

2 Hold the Ctrl key and spin the mouse wheel. The display zooms in and out.

Charting Answerset data

Charts can be created based on the data within an Answerset grid. By default, the chart appears in a new tab within the same Answer window. An option exists on the Chart Definition dialog box to display the new chart in a separate window. This would provide the option to view the chart and data at the same time.

To create a chart

1 Right-click in the Answer window and click Chart ... , or

Click the button on the Answerset toolbar.

2 On the Chart Definition dialog box select the Chart Type you wish to display

3 Enter or verify the From / To Row number for the rows to be plotted

4 Select or verify the Column(s) whose data you wish to chart

5 Select or enter any additional options for the chart, and press OK

122 Teradata SQL Assistant for Microsoft Windows User Guide

Page 123: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 3: The Answerset WindowCharting Answerset data

Table 22: Chart Definition Dialog Box

Control Description

Chart Type This drop down list allows you to select the type of chart you wish to create. The picture below shows a simple example. The default is a line chart.

Horizontal Draw Horizontal bars rather than vertical Columns. Used for Bar types only.The default is cleared.

Rectangular Draw rectangular bars rather than cylindrical bars. Used for Bar types only.The default is cleared.

3D Draw a 3D chart. The default is selected.

Note: A chart can also be changed to 2D by changing its rotation and elevation

From Row This specifies the first row to be included in the data range to be plotted.This value is pre-populated if a block of cells is currently selected.

To Row This specifies the last row to be included in the data range to be plotted.This value is pre-populated if a block of cells is currently selected.

X Axis Labels This column provides the data labels for the X Axis.Select <RowNumber> to use the row number instead of a data column.

Data Columns Select one of more numeric columns whose data you wish to chart.Only one column can be selected if the Chart Type is Pie.The highlighted columns are pre-selected if a block of cells is currently selected.

X Axis Title If entered, this text appears below the X axis labels

Y Axis Title If entered, this text appears to the left of the Y axis labels.

Chart Title If entered, this text appears above the chart.

Teradata SQL Assistant for Microsoft Windows User Guide 123

Page 124: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 3: The Answerset WindowFormatting an Answerset

Working with ChartsA legend appears at the right for pie charts and for other chart types where more than one data series (column) is plotted.

If you hover the cursor over a Pie segment or a Bar, the description of that data point and its value appears in a tool tip. For “non discreet” chart types, such as Line or Area, only the description appears.

Charts have a context menu and shortcut keys as described below:

Formatting an Answerset

You can format the colors, font name, font style, and font size of a block of cells, individual cells, rows, columns, or the entire spreadsheet. You can also specify the number of decimal places displayed and if commas appear to mark thousand separators in numeric columns. The following sections explain how to format an Answerset.

• Formatting a Block of Cells

Display Chart in a new window

Select this box to display the chart in a new window.The default is checked if the Answerset Mode is Each Resultset. Otherwise, it is cleared.

Table 22: Chart Definition Dialog Box (continued)

Control Description

Table 23: Chart Menus and Shortcut Keys

Menu Shortcut Description

Copy Ctrl+C Copy the chart to the clipboard as a picture.

Modify Display the Chart Definition dialog box which allows the chart attributes to be changed.

Set Font Change the font used on this chart.

Rotate Left Ctrl+ left arrow Rotate the chart to the left (counter-clockwise).

Rotate Right Ctrl+ right arrow Rotate the chart to the right (clockwise).

Decrease Elevation Ctrl+ down arrow Decrease the angle of elevation.

Increase Elevation Ctrl+ up arrow Increase the angle of elevation.

Ctrl+ + Zoom in.

Ctrl+ - Zoom out.

Ctrl+0 Reset to 100% zoom factor.

124 Teradata SQL Assistant for Microsoft Windows User Guide

Page 125: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 3: The Answerset WindowFormatting an Answerset

• Formatting a Single Cell

• Formatting a Single Row or Column

• Formatting Multiple Rows or Columns

• Formatting the Entire Spreadsheet

• Displaying Commas to Mark Thousand Separators

• Displaying Numbers in Scientific Notation

• Displaying Decimal Places

• Changing the Font for the Entire Window

• Zooming the Answerset Window

Formatting a Block of Cells

To format a block of cells

1 Select the area to be formatted.

2 Right-click and select Format Cells.

3 Set the formatting options you want to change.

Formatting a Single Cell

To format a single cell

1 Double-click the Answerset cell to bring up the Format Cells dialog box.

2 Set the formatting options you want to change.

Formatting a Single Row or Column

To format a single row or column

1 Double-click the row or column header to display the Format Cells dialog box.

2 Set the formatting options you want to change.

Formatting Multiple Rows or Columns

To format multiple rows or columns

1 Select the row or column to be formatted by clicking on the row or column heading and dragging to highlight.

2 Right-click to bring up the Shortcut menu.

3 Select Format Cells to bring up the Format Cells dialog box.

Teradata SQL Assistant for Microsoft Windows User Guide 125

Page 126: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 3: The Answerset WindowFormatting an Answerset

4 Set the formatting options you want to change.

Formatting the Entire Spreadsheet

To format the entire spreadsheet

1 Press Ctrl+A to highlight all cells, then right click and choose Format Cells.

The Format Cells dialog box opens.

2 Set the formatting options you want to change.

Note: The formatting change applies to the current Answerset window only.

Displaying Commas to Mark Thousand Separators

To display commas

1 Right-click in the Answerset cell you want to change and select Format Cells.

2 Select Display 1000 separators.

Displaying Numbers in Scientific Notation

To display numbers in scientific notation

1 Right-click in the Answerset cell you want to change and select Format Cells.

2 Select Use Scientific notation.

Displaying Decimal Places

To display decimal places

1 Right-click in the Answerset cell you want to change and select Decimal Places.

2 Select a number between 0 and 4.

To designate up to 14 decimal places:

a Right-click to bring up the Shortcut menu.

b Click Format Cells to bring up the Format Cells dialog box.

c Select the desired number of decimal places.

126 Teradata SQL Assistant for Microsoft Windows User Guide

Page 127: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 3: The Answerset WindowExporting a Resultset

Exporting a Resultset

Output is normally displayed in an Answerset window in table format. However, you can redirect output from future queries (ASCII or Unicode) to a delimited text file (.txt), a web page (.htm), or Microsoft Access database file (*.mdb).

This section provides the following information about exporting a Resultset:

• Exporting Results

• Single-Clicking to Display the Export File

• Saving Multiple Answersets

• Exporting to Access - Formats and Data Types

• Setting Export/Import Options

• Setting Export Options

• Setting Import Options

Exporting ResultsBefore running a query, you may redirect the Answerset.

To export results

1 Select File > Export Results.

2 Enter a statement in the Query Window.

3 Execute the query by clicking on the Toolbar.

4 In the Export File dialog box, enter a file name.

5 From the Save As Type menu, choose a file type.

• If you choose a Microsoft Access database table (.mdb) the query must consist of a single statement that returns only one Answerset. If the database or table does not exist, one is created for you.

• If you choose a delimited text file (.txt), the query may return multiple Answersets. If the specified file already exists, Teradata SQL Assistant asks you if you want to replace or append to the file.

• If you choose an HTML file (.htm). the query exports the results into an .htm format that can be viewed as a web page.

6 When the export operation is complete, a confirmation message appears in the Export Bar immediately below the toolbars.

Note: The delimiter and quotes used for exporting to a delimited text file can be set in the Options dialog box, Export tab. To set the quotes or the delimiter, see “Setting Export/Import Options” on page 129.

Warning: The export option remains in effect until you click the Export option again to cancel it.

Teradata SQL Assistant for Microsoft Windows User Guide 127

Page 128: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 3: The Answerset WindowExporting a Resultset

Single-Clicking to Display the Export FileAfter an Answerset is exported, its name and location appear in the Export Bar. Click the Export bar to automatically open and display the Answerset that was just exported.

Note: If SQLA doesn’t recognize the exported file, it uses Windows File Association to choose the appropriate application. Generally, .txt files are opened with Notepad, .htm opens a browser and .mdb opens Microsoft Access.

The figure below shows the Export bar of an exported Answerset.

Saving Multiple AnswersetsMultiple Answersets may be saved in multiple files. The file names for two Answersets or more are created by appending a number to the original file name. For example, if you specify Result.txt, and three Answersets are returned, the file names are:

Result.txtResult2.txtResult3.txt

Warning: If the specified file already exists, Teradata SQL Assistant asks if you want to replace or append to the first file in the set (in the above example, Result.txt). If the first file does not exist but other files do exist, they are overwritten with no warning.

Exporting to Access - Formats and Data Types

The following applies to exporting data to Access tables:

• If the Access database does not exist it is automatically created for you in Access 2003 format.

• When the Access Table is created, SQL Assistant maps Teradata data types to Access data types as follows:

Table 24: How SQL Assistant Maps Teradata Data Types to Access Data Types

Teradata Data Type Access Data Type

Byte, SmallInt or Integer Integer (maximum 32 bits)

BigInt, Float, Decimal or Numeric Float

Date Date

128 Teradata SQL Assistant for Microsoft Windows User Guide

Page 129: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 3: The Answerset WindowExporting a Resultset

• If the Access table already exists, the exported data either replaces or appends to it depending on whether or not you selected the Replace Table check box when specifying the table name.

Note: If the data is being appended, you must ensure that the table definition matches the data being exported. The data types of the columns should match those of the select statement used in the export - with the addition of an AutoNumber column defined as the

first column in the Access table (this is basically a row number).

Setting Export/Import Options This section explains the Export/Import tab in the Options dialog box. See “Setting Export Options” on page 130 for more information on setting the Export tab and “Setting Import Options” on page 131 for setting the Import tab.

After selecting any of these options, follow the instructions on “Exporting Results” on page 127 to learn how to export results.

After exporting an Answerset, the status bar across the bottom of the main window provides the status of the action.

To set export/import options

1 Select Tools > Options.

2 Click the Export/Import tab.

3 Select the options you want. The following table explains each option.

BLOB or CLOB Text (the LOB file name)

Other (up to 255 bytes) Text

Other (over 255 bytes) Memo

Table 24: How SQL Assistant Maps Teradata Data Types to Access Data Types (continued)

Teradata Data Type Access Data Type

Table 25: Import/Export Tab in the Options Dialog Box

Option Description

Use this delimiter between columns

Defines the column delimiter. The default value is Tab. This same character is expected to delimit the data fields in an Import file. For Import operations, ensure this character does not occur within any of the data fields unless all data values are enclosed in quotes

Enclose column data in • Double Quotes - encloses column data values in double-quotes

• Single Quotes - encloses column data values in single-quotes

• Nothing - the data values are not enclosed in quotes. This is the default value.

Teradata SQL Assistant for Microsoft Windows User Guide 129

Page 130: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 3: The Answerset WindowExporting a Resultset

For more information, see “Default Preferences (Options)” on page 156.

Setting Export OptionsThis section explains how to set export options in the Options dialog box. See “Setting Export/Import Options” on page 129 for more information on setting the Export/Import tab and “Setting Import Options” on page 131 for Import tab settings.

After selecting any of these options, follow the instructions on “Exporting Results” on page 127 to learn about exporting results.

To set export options

1 Select Tools > Options.

2 Click the Export tab.

3 Select the options you want. The following table explains each option.

For more information, see “Default Preferences (Options)” on page 156.

Table 26: Export Tab in the Options Dialog Box

Option Description

Write all exported answer sets to a single file

Writes the output from a query that contains multiple select statements to a single file. The default value of this option is cleared, meaning output from a query that contains multiple select statements is written to multiple files.

Write the SQL and result status to the export file

Writes the SQL and result status to the export file. The result status is the rows processed, elapsed time, and error messages (if any occurred). The default value of this option is cleared, meaning the SQL and result status is not written to the export file.

Write column headers to the export file

Writes column headers to the export file before the data is written. Clearing this option may be useful if you plan to Import the data back into the database at a later time. If this option is not selected, no column headers are written.The default value is selected.

Replace Carriage Returns in column data with blanks

Replaces carriage returns in column data with blanks when exporting to text files. If this option is not selected, carriage returns are left as is.The default value is cleared.

Honor the Answerset row return limit during exports

When selected, exported result sets are terminated when they reach the Maximum Row Limit set on the Answer tab. If there are multiple result sets, the limit applies to each individual set. The default value is cleared.

130 Teradata SQL Assistant for Microsoft Windows User Guide

Page 131: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 3: The Answerset WindowUnderstanding Large Object Support

Setting Import OptionsThis section explains how to set import options. See “Setting Export/Import Options” on page 129 for more information on setting the Export/Import tab and “Setting Export Options” on page 130 for settings on the Import tab.

After selecting any of these options, follow the instructions on “Exporting Results” on page 127.

To set import options

1 Select Tools > Options.

2 Click the Import tab.

3 Select the options you want. The following table explains each option.

4 Click OK to close the Options dialog box and save your settings.

For more information, see “Default Preferences (Options)” on page 156.

Understanding Large Object Support

Teradata SQL Assistant supports Large Objects. Large objects come in two types:

• Binary - These columns may contain Pictures, Music, Word documents, etc. The column type used by different vendors may be any of - BLOB, IMAGE or LONG RAW.

• Text - These columns contain text data such as Text, HTML, XML or Rich Text (RTF). The column type used by different vendors may be any of - CLOB, TEXT or LONG.

Table 27: Import Tab in the Options Dialog Box

Option Description

Ignore the first record in the file (Skip Header)

Skips the header when importing the file.The default value is cleared.

Convert localized decimal to a period on Import

Replaces the local decimal point character with a period, allowing data in the local format to be imported to a database that always expects the decimal point to be a period. Clear this check box if the database expects the decimal point to be a localized character. The default value is cleared.

Maximum batch size for simple imports

The number of data rows that are sent to the database at one time for Batch Import. The default batch size is 20 rows.

Silently discard rows that cause constraint violations

SQL Assistant ignores any errors that occur during the import operation and reports the number of rows that were imported and the number of rows discarded. The default value is cleared.

Teradata SQL Assistant for Microsoft Windows User Guide 131

Page 132: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 3: The Answerset WindowUsing Answerset Shortcut Menus

Note: When using ODBC, the ODBC Data Source option “Use Native Large Object Support” must be selected to retrieve large objects. Go to Tools > Define ODBC Data Source > Configure>Options and select Use Native Large Object Support.

When an Answerset contains a Large Object (LOB) column the action taken depends on your setting for the option “Use default file names for LOB columns”.

If this option is selected, Teradata SQL Assistant simply uses the column title as the file name stub and a default value for the file type: ‘txt’ for CLOB data, or the value specified for “Default file type for BLOB columns” for BLOB data.

If the option is not selected, SQL assistant asks you to provide a file name, a file type, and optionally, a directory for each Large Object column. Each LOB data value is written to a separate file.

The file name for each data value is created by joining the name, a sequential number, and the file type.

For example, if you provide 'Photo' as the name and 'jpg' as the type, the files are named Photo001.jpg, Photo002.jpg, and so on.

Although you may change the directory each time SQL Assistant requests a file name, only the last directory specified for a given Answerset is used. This directory is used for all LOB files related to this Answerset.

The file names appear as links within the Answerset grid. If you click on a link, the corresponding file opens. This feature relies on Windows File Associations so you must specify the file type that is appropriate for the type of data stored in the LOB column.

If the data is a graphic (file type BMP, JPG, JPEG, GIF, PNG, TGA, TIF, ICO or WMF) SQL Assistant offers you the option of displaying the picture within the Answerset grid itself. You may request that the picture be displayed instead of being saved to a file or in addition to being saved to a file.

Using Answerset Shortcut Menus

The purpose of the Shortcut menu is to provide fast access to commonly used functions. The Shortcut menu is specific to the active window. In this case, it provides a quick way for performing tasks specific to the Answerset window.

Also, you can customize the shortcut menu to provide better functionality.

Displaying the Shortcut MenuThe following table describes all of the commands on the default menu.

To display the Shortcut menu

✔ Do one of the following:

132 Teradata SQL Assistant for Microsoft Windows User Guide

Page 133: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 3: The Answerset WindowUsing Answerset Shortcut Menus

• From any table inside the Answerset window, click the right mouse button.

• Press Shift+F10.

Table 28: The Answerset Window Shortcut Menu Commands and Descriptions

Command Description

Toggle SQL / Answer

Toggles between the data in the Answerset and the SQL used to get the answer.

Copy Copies the selected text from the currently active window to the Clipboard.

Copy as HTML Copies the selected text from the currently active window to the Clipboard in HTML format.

Find Displays the Find String in Answerset dialog box, allowing you to search for a particular string in the currently active window. See “Finding a Text String in the Results Grid” on page 109.

Find Next Finds the next instance of search item.

Add Totals Displays totals at the bottom for numeric columns. The totals remain after the Answerset has been sorted.

Totals do not appear in future Answerset windows unless Add Totals is activated again.

Chart Displays the Chart Definition dialog. For more information see “Working with Charts” on page 124.

Sort Displays the Sort Answerset dialog box. For more information, see “Sorting an Answerset” on page 115.

Wrap Text Selecting Wrap Text causes text that is too long to fit within the selected cells to be wrapped into multiple lines.

Selecting this item when the selected cells are already wrapped returns the text in those cells to a single line.

Merge Cells Merges selected cells in a column in the Answerset. See “Merging Cells in the Answerset” on page 107 for more information.

Decimal Places Allows you to specify decimal places (0 to 4) in cells with numbers. Applies only to the column or columns selected. Applies to all rows even if all rows are not highlighted. For more information, see “Formatting an Answerset” on page 124.

Format Cells Allows you to format the color, font name, font style, and font size of a block of cells, individual cells, rows, columns, or the entire spreadsheet. It also allows you to add or remove decimal places and thousand separators. For more information, see “Formatting an Answerset” on page 124.

Set Font Displays a Font dialog box allowing you to change the font in the cells in the Answerset window. This new font will also be used in all future Answersets.

The Font Name and Font Size attribute are saved for future use. Separate values are stored for each type of window.

Allow Grouping Displays a Group Bar above the spreadsheet.

Teradata SQL Assistant for Microsoft Windows User Guide 133

Page 134: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 3: The Answerset WindowUsing Answerset Shortcut Menus

Freeze Column(s)

Selecting this item “freezes” the left most columns, preventing them from being scrolled off the screen when you scroll a wide Answerset to the right. All columns up to the current column or cell are frozen.

Select Freeze Columns a second time to unfreeze the columns. The default for Freeze Columns is off.

Move Column(s) Places you into “Move Columns” mode, allowing you to re-arrange the columns by clicking on a column header and dragging it to the desired position. To switch off Move Columns mode, select this item a second time. The default for Move Columns mode is off.

Note: While in this mode, columns can no longer be selected by clicking on their column headers.

Hide Column(s) Hides a single or a multiple of columns. Select the column(s) you want hidden and click Hide Column(s).

Show all Columns

Redisplays any hidden columns.

Gridlines Displays or hides the gridlines in the Answerset window. You can toggle the gridlines On or Off.

Column Headers Displays or hides column headers. You can toggle the column headers On or Off.

Row Headers Displays or hides row headers. You can toggle the row headers On or Off.

Do Not Close Prevent an Answerset window from automatically closing when a new query is executed.

If On, the current Answerset window does not close when a new query is run, even if the automatic closing of Answerset windows option is in effect. For more information on this option, see “Closing Answerset Windows Before Submitting a New Query” on page 106.

If Off, this Answerset window is closed when a new query is executed.

Table 28: The Answerset Window Shortcut Menu Commands and Descriptions (continued)

Command Description

134 Teradata SQL Assistant for Microsoft Windows User Guide

Page 135: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

CHAPTER 4

The History Window

The purpose of this section is to help you become familiar with the History window and its features and functions. This section contains the following information:

• Introduction to the History Window

• Using the History Window

• Editing History Records

• Saving, Copying, and Printing History

• Storing History Files

• The History Window Shortcut Menu

Introduction to the History Window

The History window is a table that displays your past queries and related processing attributes. The past queries and processing attributes are stored locally in a Microsoft Access 2000 database. This allows the flexibility to work with previous SQL statements in the future.

Following is an example of a History window:

Clicking any cell in the SQL Statement column in the History window copies the SQL to the Query Window.

You can display or hide the History window at any time.

For more information on additional options, see “Setting History Window Options” on page 145.

The most recently executed statement appears as the first row in the History window. The data may be sorted locally after it has been loaded into the History window. New entries are added as the first row of history no matter what sort order has been applied. For more information on sorting, see “Sorting the History Records” on page 141.

You can review all the information connected to a query in the Edit History dialog box. This dialog box also allows you to edit the query text, the attached notes, and the result message.

Teradata SQL Assistant for Microsoft Windows User Guide 135

Page 136: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 4: The History WindowIntroduction to the History Window

For additional information on this dialog box, see “Displaying and Navigating the Edit History Dialog Box” on page 147.

The Columns of the History WindowTable 29 lists the columns that appear in the History window.

If the Query text is longer than 1000 characters, it is truncated to 1000, and followed by ellipses (…). To view the entire text either click on it (to copy it to the Query window) or use the Edit History screen.

Note: The History grid displays a Result column instead of the full SqlMessage information. This column is blank unless an error occurred. To see the full Result message, hover the mouse over the Result cell.

Note: For Teradata systems only, if you abort a query in progress or decline to continue when the output limit is reached, the Rows column tells you how many rows matched the query you submitted rather than the number of rows that were actually returned to the PC. Other databases still report only the number of rows returned.

Table 29: The History Window Column Descriptions

Column Name Description

Date/Time The date and time at which the query ended.

Source The data source name used.

Elapsed The total elapsed time for the query.

Rows • Teradata only: The number of rows matching the query submitted.

• Other databases: The number of rows returned or changed.

See the second note below.

Result The result message. See the first note below.

Notes The note the user attached to the query.

SQL Statement The query text.

SQL Type The type of database accessed.

Length The length of the query, in characters.

Stmts The number of statements in the query.

Stmt Type A list of statement types used in the query. For example, CREATE TABLE, INSERT, SELECT.

User ID The user ID logged on.

DBMS Time The time spent within the database.

Fetch Time The time taken to return the data.

Seq (sequence) The order the query was submitted to the database.

136 Teradata SQL Assistant for Microsoft Windows User Guide

Page 137: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 4: The History WindowUsing the History Window

Using the History Window

This section provides the following information on using the History Window:

• Opening the History Window

• Closing the History Window

• Viewing the Result Message

• Viewing DBS Error Messages

• Viewing the History Rows

• Rearranging History Columns

• Filtering the History Rows

• Copying SQL from Previous History Record to the Query Window

• Copying SQL from Next History Record to the Query Window

• Selecting All History Rows

• Sorting the History Records

• Finding a Text String in the History Table

• Cleaning up the History table

• Magnifying the History Window

• Setting History Window Options

Opening the History Window

To open the History window

✔ Select View > Show History.

Closing the History Window

To close the History window

✔ Do one of the following:

• With the History window active, select File > Close.

• Select View > Show History to clear the check box.

Viewing the Result MessageThe History window displays a results message after a query is run. This message refers to information about the query including errors messages.

Teradata SQL Assistant for Microsoft Windows User Guide 137

Page 138: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 4: The History WindowUsing the History Window

To view the Results message

✔ Hover the mouse over the Result column cell in the History pane.

The entire message appears in a tool tip.

For additional information on error codes and how to resolve problems, refer to Messages.

Viewing DBS Error MessagesYou can view the DBS error messages by pressing F11. This shows the most recent DBS error message no matter when it occurred.

Viewing the History RowsUse the PageUp, PageDn, Ctrl+Home and Ctrl+End keys as well as scrollbars to scroll through the history rows.

Rearranging History ColumnsHistory columns can be rearranged by dragging the column header to a new position. The new column order is used each time you open the History window.

Filtering the History RowsYou can sort and filter the History rows is various ways to help organize the information.

History Filter OperatorsAll history rows are now stored in a single History database. The History Filter dialog box allows you to specify a set of filters to be applied to the history rows. The operators include >, <, =, and LIKE. The filter applies to the entire history table. When you click in the fields or boxes in the Filter dialog box, the possible operators and proper format appear at the bottom of the dialog box.

Note: The operator box accepts only applicable operators for the filter function.

To filter the History table

1 Select the History window.

2 Right-click in the History window and select Filter.

3 Set the history filter as needed. Table 30 explains the History filter options.

138 Teradata SQL Assistant for Microsoft Windows User Guide

Page 139: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 4: The History WindowUsing the History Window

Table 30: Description of History Window Filter Options

History Filter Option Description

Date Filters by date range. Clicking the combo box brings up a calendar.

Place a filter operator (>, <, =,) in the operator box.

To display the history for the most recent n days instead of basing it on a fixed date, select Previous ‘n’ days and enter the number of days in the date box.

Data Source Filter by data source name. Enter a data source name, optionally containing wildcard characters.

Select Use current Data Source to filter by the current data source only.

Note: The Use current Data Source filter option is used only when the Allow connection to multiple data sources option is not selected.

See “Setting General Program Preferences” on page 53 for information about setting this option.

User Name Shows only those rows for a specific User Name.

SQL Text Shows only those rows matching the specified string in the SQL text column.

Note: See “Using Wildcard Characters with the History Filter” on page 140 for more information on using valid wildcard characters with this option.

Notes Shows only those rows matching the specified string in the Notes column.

Note: See “Using Wildcard Characters with the History Filter” on page 140 to learn more about valid wildcard characters to use in this option.

Teradata SQL Assistant for Microsoft Windows User Guide 139

Page 140: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 4: The History WindowUsing the History Window

Using Wildcard Characters with the History FilterThe following wildcard characters are acceptable to use with the history filter:

• ‘%’ matches zero or more characters

• ‘_’ matches exactly one character

• ‘#’ matches a single numeric digit

• ‘[xyz]’ matches a single occurrence of one of the enclosed letters: x, y, or z

• ‘[0-5]’ matches a single occurrence of this range of characters: 0 to 5

Wildcard matches are not case specific. To match the percentage character (%) by itself, enclose the character in brackets. For example, enter ‘%[%]%’ in the SQL Text field to return all rows containing a % sign in the SQL text.

Copying SQL from Previous History Record to the Query WindowYou can copy the SQL from the previous History record to the Query Window.

To copy the SQL from the previous row

✔ Do one of the following:

• Select View > Previous SQL.

• Press F7.

The new SQL replaces what was previously in the Query Window.

Copying SQL from Next History Record to the Query WindowYou can copy the SQL from the next History record to the Query Window.

Statement Type Shows only those rows in which the query contains the specified statement type. For example, Select or Create Table.

Statement Count Show only those rows in which the query contains this many statements (Use operator <, > or =).

Row Count Shows only those rows in which the query effected this many rows (Use operator <, > or =).

Elapse Time Shows only those rows in which the elapsed time matches the time entered (Use operator <, > or =, and specify the time as hh:mm:ss).

Show successful queries only

Select this box to filter for successful queries only. Queries with errors are ignored.

Table 30: Description of History Window Filter Options (continued)

History Filter Option Description

140 Teradata SQL Assistant for Microsoft Windows User Guide

Page 141: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 4: The History WindowUsing the History Window

To copy the SQL from the next row

✔ Do one of the following:

• Select View > Next SQL.

• Press F8.

The new SQL replaces what was previously in the Query Window.

Selecting All History RowsYou can select all rows in the History window.

To select all history rows

✔ Do one of the following:

• With the History window active, press Ctrl+A

• Click the top left header cell in the History table.

Sorting the History RecordsThere are two ways to sort the history locally: quick sort or full sort. Full Sort allows sorting of data in multiple columns.

To sort history using quick sort

✔ Click the sort icon in any column header to sort the data by that column only.

The data is initially sorted in ascending order. Clicking the sort icon again reverses the sort order.

To sort history using full sort

1 Do one of the following:

• From the Toolbar, click .

• Right-click in the History window, then select Sort.

• Select Edit > Sort.

In the Sort dialog box, all columns in the active History window are presented in the Available Columns list.

2 Select the column name in the Available Columns list and click the Add button.

By default, the sort direction for this new sort column is ascending.

Use the up or down icons to change the sort order.

Teradata SQL Assistant for Microsoft Windows User Guide 141

Page 142: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 4: The History WindowUsing the History Window

3 To remove a sort column from the list, double-click the column name, or select it and press the Delete key or click the Remove button. You may also remove all columns from the Sort Keys list by pressing the Clear button.

If you want to reset all the columns in the Sort Keys list back to the Available Columns list box, click Clear.

4 After you have selected the columns by which you want to sort and the direction in which you want to sort, click Sort.

Note: Sorting history the Seq (sequence number) column has exactly the same effect as sorting by date and time. However, it is considerably faster.

Finding a Text String in the History TableYou can find a specific text string in the History Table.

To find text in the history grid

1 With the history table window active, select Edit > Find.

2 Complete the following options:

Table 31: Find Dialog Box

Option Description

Find What Enter the desired text string, or select an existing text string .

Match Case Select this checkbox to find text that matches the case of the search string.

Search current column only

Clear this check box to search the entire spreadsheet. If multiple cells are selected, the ‘current’ cell is marked with a bold outline.

The default is selected, but the new setting is retained if it is changed.

Note: Searches are faster when they are limited to a single column.

142 Teradata SQL Assistant for Microsoft Windows User Guide

Page 143: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 4: The History WindowUsing the History Window

Cleaning up the History tableDelete specific History rows by highlighting them in the History window and pressing the Delete button.

Use the Cleanup History dialog box to delete a large number of rows. This dialog box allows you to specify which rows to delete based on criteria such as the Date on which the query was executed and the Data Source against which the query was executed.

If multiple criteria are entered, only the rows matching all the criteria are deleted.

This dialog box can also be used to delete all duplicate rows from the History table. Rows are considered to be duplicate if both the Data Source and the SQL Text are an exact match.This option is independent from the criteria specified above.

Note: This function may take a long time if there are many rows in the History table.

To Clean the History table

1 Select the History window.

2 Right-click in the History window and select Cleanup History.

3 Set the cleanup criteria as needed. Table 32 explains the available options.

Use wildcard characters ( * and ?)

Select this checkbox to treat any question mark symbol (?) and asterisk symbol (*) in the search string as a “wildcard” character.

The question mark represents any single character. The asterisk represents any string of zero or more characters.

Find Next Click to search for the next occurrence of the search string within the current grid. The search starts at the current cell position in the grid.

Find All Click to find all occurrences of the search string and display them in a listbox. Clicking an item in the list moves the selection in Answerset to the corresponding cell. The cell appears if necessary.

Table 31: Find Dialog Box (continued)

Option Description

Teradata SQL Assistant for Microsoft Windows User Guide 143

Page 144: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 4: The History WindowUsing the History Window

Magnifying the History WindowUse the following procedure to change the magnification of the contents of a window.

Table 32: Description of Cleanup History Options

Cleanup History Option Description

Date Enter a date or click the down arrow to display a calendar to select.

Place a filter operator (>, <, =,) in the operator box.

Data Source Enter a data source name.

User Name Enter a user name.

SQL Text Enter text that appears within the SQL Text of the rows to be deleted.

Note: See also “Using Wildcard Characters with the History Filter” on page 140.

Notes Enter text that appears within the Notes of the rows to be deleted.

Note: See also “Using Wildcard Characters with the History Filter” on page 140.

Queries that failed Select this check box to delete all rows that display an error code.

Rows with an empty Notes column

Select this check box to delete all rows that do not have a Note assigned.

144 Teradata SQL Assistant for Microsoft Windows User Guide

Page 145: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 4: The History WindowUsing the History Window

To zoom the active window

1 Make sure the window is active.

2 Hold the Ctrl button and rotate the mouse wheel or press the + or - keys.

Setting History Window OptionsYou can control the History window by setting options. The following section explains how.

To set options

1 Select Tools > Options.

2 Click the History tab. The following table explains each option.

Table 33: History Tab in the Options Dialog Box

Option Description

Record queries and metadata in the History Datebase

The default is selected. This option allows SQL statements to be inserted into the History table. They are also displayed in the History window whenever a query is submitted.

When cleared, SQL queries are not logged.

Teradata SQL Assistant for Microsoft Windows User Guide 145

Page 146: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 4: The History WindowEditing History Records

Editing History Records

Through the Edit History dialog box, history records may be viewed, edited, and deleted. You may also review all the information connected to a query. Many of the fields are read only, but you may edit the SQL text, notes, and results message.

When the Edit History dialog box is first displayed, the current record is which ever cell and row is active, i.e., where you have placed your cursor, in the History window. If the History window is not open or no history record has been referenced, the current record is the last one added to the history database.

This section provides the following information on editing history records:

• Displaying and Navigating the Edit History Dialog Box

• Editing a History Record

• Compacting History

• Adding or Change a Note in a History Record

Record file name in history when using “Save As”

The default is cleared. Set this option to request that a record be added to the history file whenever you Save As query to a file.

This record contains the date/time of the save operation together with the fully qualified name of the file that you saved.

Do not save duplicate queries in History

The default is cleared. When the option is selected, duplicate queries do not appear in the History window.

Note: If the duplicate history row to be deleted contains a note, the note is copied to the new history row unless you have provided a new note when the query is executed.

Display milliseconds in elapse time fields

The default is not selected. If the option is selected, the elapse time field appears in milliseconds.

Display SQL text on a single line The default is cleared. When this option is selected, SQL text displays on one line without carriage returns.

Show Tooltip when mouse over SQL column

The default is selected. This option allows the display of up to 500 characters of the SQL text when the mouse hovers over the SQL column in the History window.

Require use of the Show History menu to close the history window

When this option is selected, the application ignores attempts to close the window by clicking the close button at the top right of the window. This prevents accidentally closing History by clicking on the wrong window.

Table 33: History Tab in the Options Dialog Box (continued)

Option Description

146 Teradata SQL Assistant for Microsoft Windows User Guide

Page 147: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 4: The History WindowEditing History Records

Displaying and Navigating the Edit History Dialog Box

To display the Edit History dialog box

1 Do one of the following:

• Select Tools > Edit History.

• Right-click in the History window and select Edit.

• Double-click the row to be edited anywhere except in the Notes cell.

2 To navigate through the history records, use the arrow buttons the bottom center of the dialog box.

The outer buttons take you to the first or last record in the history database. The inner buttons take you to the next or previous record.

Editing a History Record

To edit a history record

1 Double-click the row to be edited.

2 Within the Edit History dialog box, edit the contents of the following fields:

• SQL text

• Notes

• Result message

3 Do one of the following:

• To commit the change, click the icon.

• To cancel the change, click the icon.

You can also double-click in the Notes cell of a row in the History window. The Query Note dialog box opens so you can add or change a note.

Compacting HistoryPeriodically, you can clean up the current history file to reclaim space that may have been lost when history rows were deleted.

To compact history

✔ Select Tools > Compact History.

Adding or Change a Note in a History RecordYou can add or change the note associated with a history record.

Teradata SQL Assistant for Microsoft Windows User Guide 147

Page 148: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 4: The History WindowSaving, Copying, and Printing History

To add or change a note in a history record

1 Double-click in the Notes cell of a row in the History window.

2 In the Query Note dialog box, enter the new note information.

Saving, Copying, and Printing History

From the History window, you can save a specific part of the data by highlighting the part you want to save. If no part of the History window is highlighted, the entire contents is saved.

You cannot reload a saved history file into a new History window. There is only one History window and that is loaded from the history database.

This section provides the following information:

• Saving History Rows

• Copying Rows to the Clipboard

• Copying Rows to Notepad

• Printing the Contents of the History Window

• Cancelling Print Jobs

Saving History Rows

To save history rows

1 Ensure the History window is active.

2 Do one of the following:

• From the Toolbar, click .

• From the File menu, click Save History As.

• Press Ctrl+S.

3 In the Save History dialog box, enter a file name and choose a format type. See “File Format Types” below.

4 Choose a location and click Save.

File Format TypesYou can save the history in the following formats:

148 Teradata SQL Assistant for Microsoft Windows User Guide

Page 149: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 4: The History WindowSaving, Copying, and Printing History

Table 34: History File Format Types

File Type Description

Tab delimited [ANSI}

The data is saved in a tab-delimited file using ANSI.

If a block of cells is selected, only that block is saved. If no part of the spreadsheet is selected, the entire Answerset is saved. The column headings are saved only if they are visible on the screen.

Tab Delimited [Unicode]

The data is saved in a tab-delimited file using Unicode.

If a block of cells is selected, only that block is saved. If no part of the spreadsheet is selected, the entire Answerset is saved. The column headings are saved only if they are visible on the screen.

Tab delimited [UTF-8]

The data is saved in a tab-delimited file using UTF-8.

If a block of cells is selected, only that block is saved. If no part of the spreadsheet is selected, the entire Answerset is saved. The column headings are saved only if they are visible on the screen.

Delimited Text [ANSI]

The data is saved is a delimited text file using ANSI. To set the use of quotes or to set the delimiter between columns, see “Setting Export/Import Options” on page 129.

If a block of cells is selected, only that block is saved. If no part of the spreadsheet is selected, the entire Answerset is saved. The column headings are saved only if they are visible on the screen.

Delimited Text [Unicode]

The data is saved is a delimited text file using Unicode.

If a block of cells is selected, only that block is saved. If no part of the spreadsheet is selected, the entire Answerset is saved. The column headings are saved only if they are visible on the screen.

Delimited Text [UTF-8]

The data is saved is a delimited text file using UTF-8.

If a block of cells is selected, only that block is saved. If no part of the spreadsheet is selected, the entire Answerset is saved. The column headings are saved only if they are visible on the screen.

Microsoft Excel 2003

The data is saved as an Excel 2003 workbook containing one data sheet.

The entire Answerset is saved. Column and row headers are saved if they are currently visible.

Microsoft Excel 2007

The data is saved as an Excel 2007 workbook containing one data sheet.

The entire Answerset is saved. Column and row headers are saved if they are currently visible.

PDF Document [*.pdf]

The data is saved as a PDF file.

If a block of cells is selected, only that block is saved. If no part of the spreadsheet is selected, the entire Answerset is saved.

Web Page [*htm]

The data is saved as a table in HTML.

If a block of cells is selected, only that block is saved. If no part of the spreadsheet is selected, the entire Answerset is saved.

Teradata SQL Assistant for Microsoft Windows User Guide 149

Page 150: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 4: The History WindowSaving, Copying, and Printing History

Copying Rows to the ClipboardYou can copy rows from the History window to the Clipboard.

To copy rows to Clipboard

1 Highlight the rows you would like to copy from the History window by clicking and dragging your mouse anywhere within a row or column.

2 Do one of the following:

• From the Toolbar, click .

• From the Edit menu, select Copy.

• Right-click and select Copy.

Copying Rows to NotepadYou can copy rows from the History window to Notepad.

To copy rows to Notepad

1 Highlight the rows you would like to copy from the History window by clicking and dragging your mouse anywhere within a row or column.

2 Select File > Copy to Notepad.

Printing the Contents of the History Window

To print the contents of the History window

1 Click the History window to make it active.

2 Do one of the following:

• From the Toolbar, click .

• From the File menu, click Print.

• Press Ctrl+P.

Note: Use Print Preview to preview the job before printing.

3 The standard Windows Print dialog box appears.

XML Document The data is saved as an XML document.

No special formatting is retained. If a block of cells is selected, only that block is saved. If no part of the spreadsheet is selected, the entire Answerset is saved.

Table 34: History File Format Types (continued)

File Type Description

150 Teradata SQL Assistant for Microsoft Windows User Guide

Page 151: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 4: The History WindowStoring History Files

• To print the entire History table, under Print Range, select All.

• To print a partial section of the History table, highlight the History cells, columns, or rows you want to print. Under Print Range, select Selection.

Cancelling Print JobsYou can cancel print jobs through the Print Manager.

To cancel a print job

1 On your desktop, click Start and choose Printers and Faxes.

2 Double-click your printer.

3 In the printer window, select Document > Cancel.

Storing History Files

By default, history files are stored at: \Documents and Settings\<username>Application Data\Teradata\SQL Assistant.

However, you may want to store them in the same location as your other Microsoft Access databases or other data files.

Changing the Location of History Files

To change the location used to store history files

1 Select Tools > Options.

2 Click the File Path tab.

Note: History files maybe stored locally or on the network.

3 In the History File box, click the browse button to select a file location.

Teradata SQL Assistant for Microsoft Windows User Guide 151

Page 152: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 4: The History WindowThe History Window Shortcut Menu

If you currently have the History window open, the data in this window is replaced by that contained in the history file in this new location. If the new location does not contain a history file, one is created for you.

The History Window Shortcut Menu

The purpose of the Shortcut menu is to provide fast access to commonly used functions. The Shortcut menu is specific to the active window. In this case, it provides a quick way for performing tasks specific to the History window.

Displaying the Shortcut MenuThe following table describes the commands on the default shortcuts menu.

To display the Shortcut menu

✔ Do one of the following:

• Click the right mouse button anywhere within the History window,

• Press Shift+F10 or the Context Menu Key

152 Teradata SQL Assistant for Microsoft Windows User Guide

Page 153: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 4: The History WindowThe History Window Shortcut Menu

Table 35: The History Window Shortcut Menu Commands and Descriptions

Command Description

Copy Copies the selected text from the currently active window to the Clipboard.

Copy as HTML Copies the selected text from the currently active window to the Clipboard in HTML format.

Find Displays a Find String in History dialog box, allowing you to search for a particular string in the currently active window. See “Finding a Text String in the Results Grid” on page 109 for more information.

Find Next Finds the next item. See “Finding a Text String in the Results Grid” on page 109 for more information.

Filter Displays the History Filter dialog box which allows you to specify a set of criteria to limit the History rows that appear. For more information on the History Filter, see “Filtering the History Rows” on page 138.

Clear Filter Clears the filter that currently applies to the History window. This displays all History rows.

Sort Displays the Sort History dialog box. For more information, see “Sorting the History Records” on page 141.

Cleanup History Displays the Cleanup History dialog box which allows you to specify the criteria for rows that you want to delete from the History table, see “Cleaning up the History table” on page 143.

Wrap Text Selecting Wrap Text causes text to be wrapped into multiple lines.

Selecting this item when the selected cells are already wrapped returns the text in those cells to a single line.

Note: This feature is only useful for the SQL column on the History table.

Set Font Displays a Font dialog box allowing you to change the font in the cells in the History window.

The Font Name and Font Size attribute are saved for future use. Separate values are stored for each type of window.

Edit History Displays the Edit History dialog box. For more information, see “Editing History Records” on page 146.

Teradata SQL Assistant for Microsoft Windows User Guide 153

Page 154: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Chapter 4: The History WindowThe History Window Shortcut Menu

154 Teradata SQL Assistant for Microsoft Windows User Guide

Page 155: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

APPENDIX A

Startup Parameters and DefaultPreferences

This section contains information pertaining to:

• Startup Parameters

• Default Preferences (Options)

Startup Parameters

The following startup parameters can be passed to Teradata SQL Assistant on the command line.

When using startup parameters, any parameter value that contains spaces must be enclosed in double quotes.

For example:

sqla.exe -c Production1 -s “Select * From MyTbl”

Not:

sqla.exe -c Production1 -s Select * From MyTbl

Note: Normally the casual user does not use these startup parameters. This is normally used by DBAs or programmers.

To enter the parameter, from the Start button, select Run.

Table 36: Startup Parameters

Enter this parameter... to do the following...

-a <name> Automatically load the data contained in the tab delimited file named <name> into an Answerset window.

-c <dsn>[ [ \<user> ] \<pwd> ] Automatically connect to the data source named <dsn>, with optional <user> and <password> parameters.

-p <type> The provider type:

• Td - Connect using Teradata.NET

• Odbc - Connect using ODBC

• Ora - Connect using Oracle.NET

Teradata SQL Assistant for Microsoft Windows User Guide 155

Page 156: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Appendix A: Startup Parameters and Default PreferencesDefault Preferences (Options)

For example: sqla.exe -c Production1 -s “Select * From MyTbl”

• The parameters shown in brackets (for example, [ <mech>\ ]), are optional.

• If -a is entered, it must be the only parameter.

• If both -f and -s are entered, only the last one is used.

• For automatic execution, use -c with either -s or -f.

If the data source requires additional information, you are prompted for that information.

If you provide -c, -e and either -s or -f parameters, Teradata SQL Assistant effectively runs as a batch job. It executes the query, writes any output to the export file, then terminates.

You can also use the Windows Explorer to drag and drop a file onto the Teradata SQL Assistant executable instead of using the -f <name> startup parameter. Alternatively, you can associate a specific file type (such as .sql) with Teradata SQL Assistant. You can then start Teradata SQL Assistant and automatically load the contents of any .sql file by simply double-clicking on the file.

Default Preferences (Options)

Teradata SQL Assistant records many of your preferences. These preferences are used each time you execute Teradata SQL Assistant. Most of these settings are located on the Options tabs, and can be found by clicking Tools > Options. The following topics contain related information.

• Miscellaneous and General Default Preference Settings

-m [ <mech>\ ] <mechparm> Connect to the data source using a mechanism. Use this parameter in conjunction with the -c parameter above if a mechanism is required.

-s <SQL> Load this SQL. Automatically execute it if the -c parameter is also specified.

-f <name> Automatically load the SQL contained in the file named <name>. Automatically execute it if the -c parameter is also specified.

-e <name> Export the results of your query to a file named <name>. The format of this file is determined with Export options currently in effect. If the export file is a Microsoft Access database, the file name must be followed by a backslash '\' and the tablename.

For example: -e c:\temp\MyDatabase.mdb\MyTable

-db <name> Set <name> as the default database

-cs <name> Set the session character set to <name>

Table 36: Startup Parameters (continued)

Enter this parameter... to do the following...

156 Teradata SQL Assistant for Microsoft Windows User Guide

Page 157: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Appendix A: Startup Parameters and Default PreferencesDefault Preferences (Options)

• Query Default Preference Settings

• Code Editor Tab Default Preference Settings

• Data Format Tab Default Preference Settings

• Answerset Tab Default Preference Settings

• Export/Import Tab Default Preference Settings

• History Tab Default Preferences and Descriptions

• Database Tree Default Preferences and Descriptions

• File Paths Tab Default Preference Settings

• Page Setup Default Preferences and Settings

Miscellaneous and General Default Preference Settings

Table 37: Miscellaneous and General Default Preferences and Descriptions

Preferences Default Description

ShowTdNetWarning True Display a warning message if correct version of the .NET Data Provider for Teradata is not installed. It changes to False after the message appears.

ODBCConnectTimeout 60 The time, in seconds, that ODBC will wait for a response to a Connect request

WindowState Normal Display Teradata SQL Assistant in a normal window (not minimized or maximized)

WindowSize 900,700 The size of the Teradata SQL Assistant window on your desktop

WindowLocation 50,50 The position of the Teradata SQL Assistant window on your desktop

TabbedMDI False Use Tiled/Cascaded child windows rather than Tabbed MDI

TabGroupVertical False Use Horizontal tab groups when more than one tab group

TileWindows True Tile the windows rather than cascading them

TileVertical False Tile the windows Horizontally when tiling the child windows

ShowHistory True Show the History window at startup

ShowDBTree True Display the Database Explorer Tree after connecting to a data source

Provider ODBC Use the ODBC provider rather than the Teradata .NET provider

LastDSN The Data Source most recently connected to

LastTdDSN The Data Source most recently connected to through Teradata.NET

LastOraDSN The Data Source most recently connected to through Oracle.NET

Language Teradata The SQL language used before connecting to a data source

ANSISQL False Do not use the ANSI SQL language for syntax highlighting

OptionsTab 0 The first tab on the Options screen is the active tab

QBuilderSize 850,500 The size of the Query Builder dialog box

Teradata SQL Assistant for Microsoft Windows User Guide 157

Page 158: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Appendix A: Startup Parameters and Default PreferencesDefault Preferences (Options)

Note: *These defaults are locale dependent

QBuilderSet 0 The first SQL Set appears when Query Builder is opened

FavoriteSet * Favorites The name of the SQL Set to select in the Add To Favorites dialog box

QueryFontName * Sans Serif This font is used in the Query window

Query Font Size *8 This font sized is used in the Query window.

AnswerFontName * Sans Serif This font is used in the Answer window

AnswerFontSize * 8 This font size is used in the Answer window

HistoryFontName * Sans Serif This font is used in the History window

HistoryFontSize * 8 This font size is used in the History window

SaveTextType 1 Save Query files as *.sql

SaveGridType 1 Save Answer/History files as *.txt (ANSI text)

SaveChartType 1 Save chart files as *.jpg (JPEG format)

ExportFileType 1 Export data files as *.txt (ANSI text)

AnsFindList A list of strings to appear in the Most Recently Used list of the Find dialog box

HistFindList A list of strings to appear in the Most Recently Used list of the Find dialog box

AnsFindAllCols False The Current Column Only option is not selected when the Find dialog box is first opened for an Answerset grid

HistFindAllCols False The Current Column Only option is not selected when the Find dialog box is first opened for the History window

RecentQueryFiles A list of file names to be displayed for the Open Recent Query menu

AllowMultiConnect False Allow only one Query window (Only one Data Source)

SingleQuery False Allow multiple Query tabs in a Query window

AnswerMode 1 Display multiple result sets from a single query in tabs within an Answer window, but use separate windows for the results of each query.

AppStyle Office2003 Use Office 2003 color scheme and display style

PrintSQL False Do not print the related SQL when printing an Answerset

ScreenReader False Do not add special support for Screen Readers for the blind

BaseFontSize 8 Dialog boxes, Status bars, and the Database Tree use this font size

Table 37: Miscellaneous and General Default Preferences and Descriptions (continued)

Preferences Default Description

158 Teradata SQL Assistant for Microsoft Windows User Guide

Page 159: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Appendix A: Startup Parameters and Default PreferencesDefault Preferences (Options)

Query Default Preference Settings

Code Editor Tab Default Preference Settings

Table 38: Query Default Preferences and Descriptions

Preferences Default Description

AutoCloseAns True Close all Answerset windows when submitting a new query

DisconnectedMode False Do not connect/disconnect for every query

Audible False Do not beep when query completes

MinOnRun False Do not minimize Teradata SQL Assistant while a query is running

PromptForNote False Do not prompt for a note when submitting a query

StopOnError True Stop at the first error in a multi-statement query

RunSelectedOnly False Submit the entire query even when part is highlighted

AllowNamedParms True Parameter substitution allowed in queries

SaveQueryLog False Do not prompt to save the query log after a multi-statement Query has completed

PromptToSave True Prompt to save a Query that has been changed before closing a Query tab

Table 39: Code Editor Tab Default Preferences and Descriptions

Preferences Default Description

AutoSyntax True Perform syntax coloring as you type

UpperCase False Do not convert keywords to upper case in the Query window

ShowLineNo False Do not display line numbers in the Query window

ShowMargin True Display a margin at the left of the Query window

ShowWhitespace False Do not show symbols for whitespace characters

ShowBraceMatch True Highlight start/end braces including parens, quotes, comment delimiters, and keywords such as CASE/END

ExpandTabs False Do not expand tabs (replace with spaces)

AutoIndent True Automatically indent new lines to match the line above

Intellisense False Do not display suggestions (dropdown lists) as you type

IncludeTables False Include Tables as well as Views in the suggestion lists

LineSize 60 Format Query wraps text at first comma after column 60

TabSize 4 Tab key inserts 4 space characters in the Query Window

ColorBack White The background color in the Query window

ColorKeyword Blue The color used for Keywords

Teradata SQL Assistant for Microsoft Windows User Guide 159

Page 160: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Appendix A: Startup Parameters and Default PreferencesDefault Preferences (Options)

ColorFunction Blue The color used for built-in Functions

ColorString Magenta he color used for Strings and Numbers

ColorComment Dark Green The color used for Comments

ColorName Maroon The color used for Object Names and aliases

ColorParam Red The color used for Parameter markers and control words (RUN)

ColorOther Black The color used for any other text in the Query window

ColorMargin Smoke The color of the left margin

ColorBookmark Cyan The color of a bookmark (in the margin)

ColorBraceMatch Black The color used to highlight braces is an average of this color and the background color

ColorRunning Light Coral The background color of a tab while the Query is executing

TabColorComplete Pale Green The color of a non-active tab after its Query completes

TempTableColor Blue The color of a Global Temporary Table in the Database Tree

ColorExpStmtType Fuchsia The color used for the Statement Type keyword of each Explain step

ColorExpName Blue The color used for object names in Explain text

ColorExpWarning Red The color used for text that may indicate a performance impact in the Explain text

ColorExpKeyword Green The color used for phrases that may be important when reading the explain text

ColorEditAdd Pale Cream The background color of the 'Insert New' row in the Edit Table grid

ColorEditChanged Gold The background color of changed rows in the Edit Table grid

StyleComment 2 Comments appear in Italics

StyleKeyword 1 Keywords appear as Bold text

StyleFunction 0 Built-in Functions appear as regular text

StyleParam 1 Parameter markers and Commands appear as Bold text

StyleName 0 Object names appear as regular text

StyleString 0 Strings appear as regular text

StyleOther 0 The remaining text appear as regular text

Table 39: Code Editor Tab Default Preferences and Descriptions (continued)

Preferences Default Description

160 Teradata SQL Assistant for Microsoft Windows User Guide

Page 161: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Appendix A: Startup Parameters and Default PreferencesDefault Preferences (Options)

Data Format Tab Default Preference Settings

Answerset Tab Default Preference Settings

Table 40: Data Format Tab Default Preferences and Descriptions

Preferences Default Description

BinAsBlobSize 30 BYTE columns larger than 30 are treated as BLOBs

CharAsClobSize 16384 CHAR columns larger than 16384 are treated as CLOBs

DashesInBinary True Include dashes between bytes in binary data

DateFormat NA Display dates using the current Windows locale settings

NullString ? Display a '?' when the column value is null

Dec16AsStr False Do not display Decimal(16), and above, values as character strings (used for Excel compatibility)

NumDecimals 2 Two decimal places appear for data that originates from Float columns

Table 41: Answerset Tab Default Preferences and Descriptions

Preferences Default Description

UseAltColor False Do not use alternating row background colors in Answerset

AltRowColor Pale Green Use this color in alternate rows, if requested

MoveMode False Do not open new answer windows in 'Move Columns' mode

GridLines True Display gridlines in new Answerset windows

ShowThousandSep True Display thousand separators in numeric columns

NegativeRed False Do not show negative values in red

DisplayTitles True Display the column titles rather than column names in the column headers of Answerset windows

WrapHeaders True Wrap column headers across 2 lines if the widest data value is narrower than the column header

UseScientific False Display ‘Float’ data as a decimal value rather than in scientific notation

NoPromptLob False Always prompt for the file name and file type when LOB columns are returned

DefBlobType jpg Blobs will be assumed to be JPEG files

MaxAnswerRows 2000 A maximum of 2000 Answerset rows is returned before asking whether more rows should be returned

ColWidthRowLimit 500 Look only at the first 500 rows when determining the default column width

Teradata SQL Assistant for Microsoft Windows User Guide 161

Page 162: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Appendix A: Startup Parameters and Default PreferencesDefault Preferences (Options)

Export/Import Tab Default Preference Settings

History Tab Default Preferences and Descriptions

Table 42: Export/Import Tab Default Preferences and Descriptions

Preferences Default Description

ColumnDelimiter {tab} Use a tab character as the delimiter between columns in export and import files

ColumnQuote Do not enclose the data fields in quotes (or expect in Import)

ExportOneFile False Export results from multiple statements to separate files

ExportWriteSQL False Do not write SQL and result status to the export file

ExportWriteHeader True Write column headers to the export file

RemoveCrLf False Do not remove carriage returns from exported text values

LimitExports False Do not prompt the user when the Answerset row limit is reached

ImportConvert False Do not convert the localized decimal point to a period on import. (Option is only enabled when the decimal point is not a period.)

ImportSkipHeader False Do not skip the header record (first line) of imported files

ImportBatchSize 20 Submit 20 rows worth of data at a time when Importing data (not ODBC)

ImportIgnoreError False Do not ignore errors, such as duplicate inserts, when using Batch Import

Table 43: History Tab Default Preferences and Descriptions

Preferences Default Description

HistoryUpdate True Update the history table (and window if it is visible)

HistorySaveQry False Do not write "Save Query" records to the history file.

HistoryNoDups False Save all queries in the History window, including duplicates

HistoryMilliseconds False Display elapsed times in seconds (do not show milliseconds)

HistorySQLNoCR False The SQL Text appears with line feeds intact. Only the text on the first line is shown unless Wrap Text is applied. You can also display a tooltip by hovering over the text with your mouse. See “The History Window Shortcut Menu” on page 152.

HistorySQLTips True Display the full SQL Text when hovering over the text with your mouse.

HistoryNoClose False Allows you to close the History window by clicking the close button on the top right corner of the window.

HistoryColOrder 0,1,2,3, … The history window columns appear in this order

HistoryFilter No filter is applied initially

162 Teradata SQL Assistant for Microsoft Windows User Guide

Page 163: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Appendix A: Startup Parameters and Default PreferencesDefault Preferences (Options)

Database Tree Default Preferences and Descriptions

File Paths Tab Default Preference Settings

Page Setup Default Preferences and Settings

Table 44: Database Tree Default Preferences and Descriptions

Preferences Default Description

LoadDBTreeAll False Load a user defined list of databases into the database tree.

DBTreeSource DBC.DatabasesX

When adding all databases, this is the table/view that is read to obtain the list

ExcludeUsers True When adding all databases, only the databases and not the users are loaded

SaveTreeData False Do not save the Database Explorer Tree data to a file and reload it next time

UseFastSchema False Use the standard catalog functions to return both the column name and the data type for each column in a view.

UseCatalog False Use the ODBC 'schema' field (not 'catalog') for ‘unknown’ vendor databases

QualifyNames False Do not qualify object names with their parent names when dragging objects from the Database Tree

QuoteNames False Do not enclose object names in double quotes when dragging objects from the Database Tree

Table 45: File Paths Tab Default Preferences

Option Default path

Query files C:\Documents and Settings\<username>\My Documents

Answer files C:\Documents and Settings\<username>\My Documents

Import and LOB files C:\Documents and Settings\<username>\My Documents

History File C:\Documents and Settings\<username>\Application Data\Teradata\SQL Assistant.

Table 46: Page Setup Defaults and Descriptions

Preferences Default Description

Page Top 70 Provide a 0.7 inch margin at the top of the page

PageLeft 70 Provide a 0.7 inch margin at the left of the page

PageBottom 30 Provide a 0.3 inch margin at the bottom of the page

PageRight 40 Provide a 0.4 inch margin at the right of the page

PageColor False Print in black and white

PageSize Letter Print to standard (US) Letter size paper (11 x 8.5)

Teradata SQL Assistant for Microsoft Windows User Guide 163

Page 164: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Appendix A: Startup Parameters and Default PreferencesDefault Preferences (Options)

PageOrient 2 Print in Landscape

PageBorder False Do not print a bold border around the output

PageZoom 100 Print the spreadsheet at its original size (100%)

Table 46: Page Setup Defaults and Descriptions (continued)

Preferences Default Description

164 Teradata SQL Assistant for Microsoft Windows User Guide

Page 165: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

APPENDIX B

Menus, Toolbars and Shortcuts

The purpose of this section is to assist you with Menus and Toolbars. This section contains:

• Using Toolbars and Buttons

• Customizing Menus and Toolbars

• General Command Shortcut Keys

• Query Specific Shortcut Keys

• Window Control Shortcut Keys

• Answer / History Specific Shortcut Keys

Using Toolbars and Buttons

This set of topics explains the tool bars and buttons used in Teradata SQL Assistant. The following topics are included.

• The Main Toolbar

• The Answerset Toolbar

• The Query Toolbar

• Toolbar Button Descriptions

The Main ToolbarThe Main Toolbar appears along the top of the Teradata SQL Assistant window. The available commands apply to the active window.

A tool button is gray when the command is not available.

Figure 1: The Default Main Toolbar

See “Toolbar Button Descriptions” on page 166 for a description of all the tool buttons.

The Answerset ToolbarThe default position of the Answerset Toolbar is below the Main toolbar, to the right of the Query toolbar. The available commands apply to the active window.

Teradata SQL Assistant for Microsoft Windows User Guide 165

Page 166: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Appendix B: Menus, Toolbars and ShortcutsUsing Toolbars and Buttons

Figure 2: The Default Answerset Toolbar

See “Toolbar Button Descriptions” on page 166 for a description of all the tool buttons.

The Query ToolbarThe default position of the Query Toolbar is below the main toolbar. The available commands apply to the active window.

Figure 3: The Default Query Toolbar

See “Toolbar Button Descriptions” on page 166 for a description of all the tool buttons.

Toolbar Button DescriptionsThe default toolbar buttons are described in the following table.

Table 47: Toolbar Button Descriptions

Toolbar Button Name Menu Description

Connect Main Toolbar Allows you to select a data source and connect. See “Connecting to and Disconnecting from a Data Source” on page 30 for more information about connecting to data sources.

Disconnect Main Toolbar Click to disconnect from the current data source.

Data Provider Main Toolbar Use the drop down box to select the data provider you want to use. The providers include ODBC and .NET for Teradata or Oracle. See “Defining a Data Source” on page 22 for more information.

New Query File Opens a new tab in the Query Window. This selection is only available if the option “Allow multiple queries per connection” is selected.

Open Query File Opens a previously saved query or reads a file into the Query Window.

Close All Queries tabs

File Closes all queries. This selection is only available if the option “Allow multiple per connection” is selected.

Save File Saves the contents in the active window.

Save As File Saves the contents in the active window after prompting for a new file name.

Copy to Notepad

File Runs the Microsoft Windows Notepad application and transfers the contents of the active window for additional editing.

166 Teradata SQL Assistant for Microsoft Windows User Guide

Page 167: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Appendix B: Menus, Toolbars and ShortcutsUsing Toolbars and Buttons

Print Preview File Allows you to preview the Answerset and History window before printing. See “Using Print Preview” on page 57 for more information.

Print File Prints the contents of the active window.

Export Results File Exports future query results to a Microsoft Access or delimited text file.

Import Data File Switches on import mode where parameter data is read from a text file.

Undo Edit Undoes the last change made in the Query Window.

Redo Edit Redoes the last change made in the Query Window.

Cut Edit Cuts the selected text to the Clipboard.

Copy Edit Copies the selected text to the Clipboard.

Paste Edit Pastes the contents of the Clipboard into the Query Window.

Clear Query Edit Clears the current query

Format Query Edit Formats the query by adding line breaks and indentation at appropriate points.

Right-to-left Editor

Edit Opens an Editor window for writing queries in languages that use a right-to-left format. See “Using the Right-to-Left Editor for Queries” on page 84 for more information.

Find Edit Searches the active window for the desired text string.

Find Next Edit Searches for the next occurrence of the string that was specified in the previous Find command in the active Window. If you have not yet issued a Find command, it acts as a Find command.

Find Previous Query Toolbar

Searches for the previous occurrence of the string that was specified in the previous Find command in the active Window. If you have not yet issued a Find command, it acts as a Find command.

Replace Edit Finds and replaces any or all occurrences of a particular string in the Query Window.

Add Totals Edit Displays totals at the bottom of numeric columns. The totals remain after the Answerset has been sorted. Totals do not appear in future Answerset windows unless Add Totals is activated again.

Table 47: Toolbar Button Descriptions (continued)

Toolbar Button Name Menu Description

Teradata SQL Assistant for Microsoft Windows User Guide 167

Page 168: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Appendix B: Menus, Toolbars and ShortcutsUsing Toolbars and Buttons

Sort Edit Sorts the data in the active window.

Explorer Tree View Displays or hides the Database Explorer Tree.

Go To Favorites

View Moves focus to the Favorites pane, first displaying it if it is not currently visible.

Set Font View Allows you to change the font type, style, and size in the active window

Show History View Displays or hides the History window.

Previous SQL View Copies the SQL from the previous history record to the Query Window.

Next SQL View Copies the SQL from the next history record to the Query Window.

Execute Tools Executes the SQL statement(s) in the Query Window. Each statement is submitted separately.

Abort Tools Aborts an executing, or in-flight, query.

Execute Parallel

Tools Executes the SQL statement(s) in the Query Window. The entire query is submitted as a single request.

Reconnect Tools Reconnect the current Query window to a connection that was dropped for some reason, such as the client PC going into Hibernating mode.

Explain Tools Displays an Explain plan for the query.

Visual Explain Tools Opens Teradata Visual Explain so you can display a visual EXPLAIN of a single-statement query currently in the Query Window.

Note: You can move this command to a menu or Toolbar only if:

• You have the Teradata Visual Explain application (version 3.0 or later) installed on your PC, and

• If you are connected to a database.

Teradata Query Scheduler

Tools Opens Teradata Query Scheduler so you can schedule your query for later execution.

Note: You can move this command to a menu or Toolbar only if:

• You have the Teradata Query Scheduler (Teradata TQS) application (version 5.0 or later) installed on your PC, and

• If you are connected to a database.

Table 47: Toolbar Button Descriptions (continued)

Toolbar Button Name Menu Description

168 Teradata SQL Assistant for Microsoft Windows User Guide

Page 169: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Appendix B: Menus, Toolbars and ShortcutsUsing Toolbars and Buttons

List Tables Tools Displays the Table List dialog box where you can enter the name of the database whose tables or views you want to list. The resulting list of tables or view displays in an Answerset window.

List Columns Tools Displays the Column List dialog box where you can list the columns in a particular table or view in the selected database. The resulting list of columns displays in an Answerset window.

Edit History Tools Opens the Edit History dialog box. See “Editing History Records” on page 146 for more details.

Cascade Window Cascades all the child windows within the Teradata SQL Assistant parent window.

Tile Horizontal

Window Tiles the child windows horizontally to fit within the Teradata SQL Assistant parent window.

Tile Vertical Window Tiles the child windows vertically to fit within the Teradata SQL Assistant parent window.

New Horizontal Tab Group

Window This button moves the current window to a new tab group, created below the current tab group.

New Vertical Tab group

Window This button moves the current window to a new tab group, created next to the current tab group.

Help Topics Help Displays the contents tab for the Help file.

Audible Notification

Query Shortcut

Prompts your system to beep when the query has completed and all data has been returned to your PC. The beep also occurs if the query times out, the number of rows exceeds the output limit, or the query is canceled. It is also located on the Query shortcut menu.

Minimize on Execution

Query Shortcut

Automatically minimizes the Teradata SQL Assistant window when a query is being processed.

Prompt for Notes

Query Shortcut

Prompts you for a note before running any query. This option causes the system to display an input dialog box whenever you submit a query.

Add to Favorites

Query Shortcut

Adds the current query or selected text to a Favorites collection. Once the query is added as a favorite, it can be selected for reuse from the Query Builder window. See “Adding a Query to Favorites” on page 80.

Query Builder Query Shortcut

Opens the Query Builder window.

Insert Date Query Shortcut

Inserts the current date in the Query where ever the cursor is placed.

Bookmark Query Toolbar

Adds or removes a bookmark at the current line

Table 47: Toolbar Button Descriptions (continued)

Toolbar Button Name Menu Description

Teradata SQL Assistant for Microsoft Windows User Guide 169

Page 170: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Appendix B: Menus, Toolbars and ShortcutsUsing Toolbars and Buttons

Next bookmark

Query Toolbar

Moves to the next bookmark

Previous bookmark

Query Toolbar

Move to the previous bookmark

Remove All Bookmarks

Query Toolbar

Removes all bookmarks

Show White Space

Query Toolbar

Displays symbols for tabs and spaces

Indent Query Toolbar

Indents text to the right

Unindent Query Toolbar

Unindents text (to the left)

Comment Text

Query Toolbar

Turns the selected text (or the current line, if no text is selected) into a comment, or turns the current comment into text

Select Block Query Toolbar

Selects a logical block of text when the cursor is positioned at either the start or end delimiter. (For comments, parens, Case/End, etc.)

Delete blank lines

Query Toolbar

Deletes blank lines from a currently selected part of a query

Convert tabs to spaces

Query Toolbar

Converts tabs to spaces in a query

Uppercase Query Toolbar

Converts the selected text to uppercase

Lowercase Query Toolbar

Converts the selected text to lowercase

Set Repeat Count

Query Toolbar

Sets the number of times the next keyboard command or macro is executed

Record Macro Query Toolbar

Records a keystroke macro for later playback

Play Macro Query Toolbar

Plays back the previously recorded macro

Delete Macros Query Toolbar

Deletes all previously recorded keyboard macros and the keyboard shortcut keys assigned to them

Column Headers

Answerset Shortcut

Displays or hides column headers

Toggle SQL/Answer

Answerset Shortcut

Switches between displaying the SQL statement that generated the Answerset or the Answerset data

Table 47: Toolbar Button Descriptions (continued)

Toolbar Button Name Menu Description

170 Teradata SQL Assistant for Microsoft Windows User Guide

Page 171: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Appendix B: Menus, Toolbars and ShortcutsUsing Toolbars and Buttons

Move Columns

Answerset Shortcut

Places you into “Move Columns” mode, allowing you to re-arrange the columns by clicking on a column header and dragging it to the desired position. To switch off Move Columns mode, click on this item a second time. The default for Move Columns mode is off.

Note: While in this mode, columns can no longer be selected by clicking on their column headers.

Chart Answerset Shortcut

Displays the Define Chart dialog box to allow you to specify the columns and rows to be charted, along with the chart type and other criteria.

Freeze Columns

Answerset Shortcut

Selecting this item “freezes” the left most columns, preventing them from being scrolled off the screen when you scroll a wide Answerset to the right. All columns up to the current column or cell are frozen.

Click on 'Freeze Columns' a second time to unfreeze the columns. The default for 'Freeze Columns' is 'Off '.

Decimal Places

Answerset Shortcut

Displays a menu that allows you to select the number of decimal places to be displayed in the current column

Group Columns

Answerset Shortcut

Allows grouping

Grid Lines Answerset Shortcut

Displays or hides gridlines in the current Answerset window

Merge Cells Answer Shortcut

Merges cells that contain the same data in consecutive rows of the Answerset

Row Headers Answer Shortcut

Displays or hides row headers

Wrap Text Answer Shortcut

Wraps the text onto multiple lines if it does not fit entirely within the column on 1 line

Allow Close Answer Shortcut

Allows automatic closing of the selected Answerset window

Do Not Close Answer Shortcut

Prevents automatic closing of the selected Answerset window

Copy as HTML

Answer Shortcut

Copies the selected text from the currently active window to the Clipboard as HTML

Format Cells Answer Shortcut

Allows you to set the formatting options for the selected cells

Filter History Shortcut

Opens the History filter dialog box. See “Filtering the History Rows” on page 138 for more information.

Clear Filter History Shortcut

Clears the History filter

Table 47: Toolbar Button Descriptions (continued)

Toolbar Button Name Menu Description

Teradata SQL Assistant for Microsoft Windows User Guide 171

Page 172: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Appendix B: Menus, Toolbars and ShortcutsCustomizing Menus and Toolbars

Customizing Menus and Toolbars

By customizing Menus and Toolbars, you can remove commands you never use or add commands you frequently use.

Some commands have images associated with them so you can quickly associate the command with the corresponding image. You can drag a command to a menu or Toolbar to make the command easier to gain access to.

We recommend customizing the shortcut menus and Toolbars, and limit customizing main menus to only changing the order of menu commands. This enables the procedures in this user guide to correspond to the set up on your PC.

To find information on main menu items, refer to the Index under the main menu name.

Note: When you customize the menus or toolbars, your preferences are saved in a file named Toolbars.config located in\Users\<username>\AppData\Teradata\SQL Assistant on Windows 7 or \Documents and Settings\<username>\Application Data\Teradata\SQL Assistant otherwise.

This section contains the following information about the customization of menus and toolbars:

• Adding a Command to a Menu or Toolbar

• Menu Commands Only

• Removing a Command from a Menu or Toolbar

• Moving a Command

• Adding or Removing a Break Between Commands

• Changing the Name for a Command

• Assigning or Changing a Keyboard Shortcut

• Changing Menu Behavior

• Showing Recently Used Commands First

• Resetting the Default Menu Bar

• Hiding the Toolbars

• Showing or Hiding Toolbar Screen Tips

• Adding, Removing, Renaming, or Resetting a Toolbar

Adding a Command to a Menu or ToolbarSome commands do not have images and these commands should be used to customize menus instead of Toolbars. For a list of these commands, see “Menu Commands Only” on page 173.

172 Teradata SQL Assistant for Microsoft Windows User Guide

Page 173: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Appendix B: Menus, Toolbars and ShortcutsCustomizing Menus and Toolbars

To add a command to a menu or Toolbar

1 From the Tools menu, click Customize.

2 Click the Commands tab to see the available commands.

3 In the Categories box, click on each category to see the available commands in the Commands box.

Commands are grouped into categories that match the main menu names, however, you are not restricted to adding them to a particular menu or Toolbar.

4 Click on the command in the Commands box and drag it to the menu or Toolbar you want to add it to.

When the mouse passes over the menus, they open to display their current contents.

When the mouse passes over the Toolbar, the pointer looks like an I-beam to help guide you in placing the button.

5 Move the cursor to the position in a menu or on a Toolbar where you want to insert the new command and then release the mouse button.

Menu Commands OnlySome commands do not have images and these commands should be used to customize menus instead of Toolbars. These commands are:

Removing a Command from a Menu or ToolbarYou can remove commands from menus or Toolbars. However, the following commands in the default menu cannot be deleted: Exit, Customize, Connect, Help Topics, and About.

To remove a command from a menu

1 From the Tools menu, click Customize.

The Customize dialog box opens.

2 Click on the menu to open it.

3 Click on the command you want to remove and drag it away from the menu.

4 Release the mouse button when the cursor shows a small x.

• ANSI SQL

• Arrange Icons

• Change Password

• Cleanup History

• Close

• Compact History

• Customize

• Define Data Source

• Go to Explorer

• Hide Columns

• Open Answerset

• Open Recent Queries

• Options

• Page Setup

• Select All

• Set Title

• Show All Columns

• Show Last Error

• Status Bar

• Tabbed

• Toolbar

Teradata SQL Assistant for Microsoft Windows User Guide 173

Page 174: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Appendix B: Menus, Toolbars and ShortcutsCustomizing Menus and Toolbars

To remove a command from a Toolbar

1 From the Tools menu, click Customize.

The Customize dialog box opens.

2 Click on the Toolbar button you want to remove and drag it away from the Toolbar.

3 Release the mouse button when the cursor shows a small x.

Moving a Command

To move a command

1 From the Tools menu, click Customize.

The Customize dialog box opens.

2 Click to open the menu that contains the command you would like to move.

3 Click on the command you want to move and drag it to its new location which can be on the same menu, different menu, or a Toolbar.

Adding or Removing a Break Between Commands

To add or remove a break (line or bar) between commands

1 From the Tools menu, click Customize.

The Customize dialog box opens.

2 Click on the menu that contains the command.

3 When the menu opens, right click on the command that you want to be after the break.

4 Choose Begin a Group.

Changing the Name for a Command

To change the name that appears for a command

1 From the Tools menu, click Customize.

The Customize dialog box opens.

2 Click to open the menu that contains the name of the command you want to change.

3 When the menu opens, right click on the command that you want to change.

4 Enter a new name.

Assigning or Changing a Keyboard ShortcutYou can assign or change keyboard shortcuts for a command.

174 Teradata SQL Assistant for Microsoft Windows User Guide

Page 175: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Appendix B: Menus, Toolbars and ShortcutsCustomizing Menus and Toolbars

To assign or change keyboard shortcuts

1 Select Tools > Customize.

The Customize dialog box appears.

2 Click Keyboard.

The Customize Keyboard dialog box appears.

3 Select a category in the Categories list.

4 Select a command in the Commands list.

5 Select a shortcut in the Specify a Shortcut menu.

6 Click Assign.

To remove a previously assigned shortcut, click Remove.

7 Click Close.

Changing Menu BehaviorYou can select five different styles that affect the way your menus appear.

To change the menu behavior

1 From the Tools menu, click Customize.

The Customize dialog box opens.

2 Choose the Options tab.

3 Use the Menu animations list and select Random, Unfold, Slide, Explode or Fade in.

4 Click Close.

Showing Recently Used Commands FirstYou can choose between seeing all commands or only those commands that you have recently used.

To change this setting

1 Select Tools > Customize.

2 Click the Options tab.

3 To see all commands, clear the Menus show recently used commands first.

To only see only those commands that you have recently used, select the Menus show recently used commands first. After selecting this option, you can also select the option which enables you to view the full menus after a short delay by selecting the Show full menus after a short delay check box.

To clear or reset the usage information so none of the commands are considered “recently used,” click Reset my usage data.

Teradata SQL Assistant for Microsoft Windows User Guide 175

Page 176: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Appendix B: Menus, Toolbars and ShortcutsCustomizing Menus and Toolbars

Resetting the Default Menu Bar

To reset the default menu bar

1 Select Tools > Customize.

The Customize dialog box opens and the Toolbars tab is on top.

2 In the Toolbars box, click Menus once to highlight.

3 Click Reset.

4 In the Reset Toolbar dialog box, choose Original State or Last Loaded State.

5 Click OK and then click Close.

Hiding the Toolbars

To hide the Toolbars

✔ Select View > Toolbars (or right click anywhere on the toolbar), and select the Toolbar you want to hide. The check mark next to Toolbar name toggles Off to indicate the Toolbar has been disabled and no longer displays.

Showing or Hiding Toolbar Screen TipsScreenTips are brief descriptions that display when you pass the mouse pointer over a Toolbar button.

To change this option

1 From the Tools menu, click Customize.

2 Choose the Options tab.

3 Select or clear the Show ScreenTips on Toolbars check box

Adding, Removing, Renaming, or Resetting a Toolbar

To add, remove, rename, or reset a Toolbar

1 From the Tools menu, click Customize.

The Customize dialog box opens and the Toolbars tab is on top.

Table 48: Adding, Deleting, Renaming and Resetting a Toolbar

To... Do the following...

Add a new Toolbar 1 Click New.

2 In the New Toolbar dialog box, type the name of the new Toolbar.

176 Teradata SQL Assistant for Microsoft Windows User Guide

Page 177: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Appendix B: Menus, Toolbars and ShortcutsGeneral Command Shortcut Keys

2 Click Close.

Note: To add commands to a Toolbar, see “Adding a Command to a Menu or Toolbar” on page 172.

General Command Shortcut Keys

The following table lists the command shortcut keys available in SQL Assistant.

Delete an existing Toolbar

1 Select the Toolbar you want to delete from the Toolbars box.

2 Click Delete in the Delete Toolbar dialog box.

Note: You cannot delete the default Toolbars named Toolbar.

Rename a Toolbar 1 Click Rename.

2 In the Rename Toolbar dialog box, type a new name.

Note: You cannot rename the default Toolbars named Toolbar.

Reset a Toolbar 1 Click Reset.

2 In the Reset Toolbar dialog box, choose Original State or Last Loaded State.

Note: You can only reset the default Toolbars.

Table 48: Adding, Deleting, Renaming and Resetting a Toolbar (continued)

To... Do the following...

Table 49: Shortcut Keys

Shortcut Keys Menu/Command Description

F1 N/A Displays context sensitive help

Ctrl+N File > New Query Clears the Query Window for entry of new query

Ctrl+O File > Open Query Displays the Open Query dialog box

Ctrl+S File > Save Saves the contents of the current window to a file

Ctrl+P File > Print Prints the contents of the current window

Ctrl+Y Edit > Redo Redoes a previously Undone change

Ctrl+Z Edit > Undo Undoes the last change made in the active Query window

Ctrl+X Edit > Cut Cuts the last change made in the active Query window

Ctrl+C Edit > Copy Copies the last change made in the active Query window

Ctrl+V Edit > Paste Pastes the last change made in the active Query window

Ctrl+Q Edit > Format Query Formats the query in the Query Window

Ctrl+F Edit > Find Searches the active window for the desired text string

Teradata SQL Assistant for Microsoft Windows User Guide 177

Page 178: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Appendix B: Menus, Toolbars and ShortcutsQuery Specific Shortcut Keys

Query Specific Shortcut Keys

The following table lists the shortcut keys that are specific to the Query window.

F3 Edit > Find Next Finds the next occurrence of the string that was specified in the previous Find command

Shift+F3 Edit > Find Previous Finds the previous occurrence of the string that was specified in the previous Find command

Ctrl+H Edit > Replace Finds and replaces a particular string in the active window

F4 Edit > Add Totals Displays totals at the bottom of numeric columns

Ctrl+A Edit > Select All Selects everything in the current window

Ctrl+G View > Go To Explorer Moves your cursor to the Database Explorer Tree

F7 View > Previous SQL Moves the active cell in the History window to the previous row and copies the query from this new row into the Query Window

F8 View > Next SQL Moves the active cell in the History window to the next row and copies the query from this new row into the Query Window

F11 View > Last Error Displays the most recent SQL error message allowing you to see the full text of a message that is too long to fit on the status bar

F5 Tools > Execute Submits the query that is currently in the Query Window. Each statement in the query is submitted separately to the database

F6 Tools > Explain Issues an EXPLAIN

F9 Tools > Execute Parallel Submits the entire query that is currently in the Query Window as a single request

F10 Tools > Abort Aborts the currently executing query

Shift+F10 or <Right-Click>

N/A Display the context menu for this window

F12 Window > Set Title Sets a title for an Answerset

Table 49: Shortcut Keys (continued)

Shortcut Keys Menu/Command Description

Table 50: Query Specific Shortcut Keys

Shortcut Keys Description

Ctrl+B Adds or removes the bookmark at the current line

Ctrl+D Turns the selected text (or the current line, if no text is selected) into a comment, or turns the current comment into text

Ctrl+E Executes Macro 1

178 Teradata SQL Assistant for Microsoft Windows User Guide

Page 179: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Appendix B: Menus, Toolbars and ShortcutsQuery Specific Shortcut Keys

Ctrl+I Removes all bookmarks

Ctrl+L Converts selected text to lowercase

Ctrl+M Records a macro.

Note: When macro recording is complete, you are prompted to assign a Hot Key combination to play this macro. Since all function keys and most CTRL+x combinations are already used, use CTRL+Fn or CTRL+SHIFT+x.

Ctrl+R Sets the repeat count.

Note: When you set a repeat count, the next keyboard command you execute is repeated that number of times. This is most useful for playing your macros, or for such things as “Extend to end of word” (CTRL+Shift+).

Ctrl+T Deletes the current query in the Query window

Ctrl+U Converts the selected text to uppercase

Ctrl+W Display or Hide white space characters

Ctrl+F2 Moves the cursor to the next bookmarked line in a multiple line query

Ctrl+] Moves the cursor to the matching brace (for example, from “(“ to “)”, or from “Begin” to “End”)

Ctrl+/ Comment or un-comment the selected text.

Ctrl+Space Displays suggested name list, if appropriate

Ctrl+Shift+Space Adds the last table/view/alias name in a FROM clause to the Active List.

Note: This key combination should only be used when the cursor immediately follows that object or alias name

Alt+Up arrow Moves the current/selected line(s) up

Alt+Down arrow Moves the current/selected line(s) down

Alt+Insert Inserts a new line above the current line

Alt+Delete Deletes the current line

Ctrl+Shift+N Inserts a new line above the current line

Ctrl+Shift+] Selects a logical block (when a brace match is highlighted)

Ctrl+Shift+Del Deletes all blank lines within the selected text

Tab Indent lines (only if text is selected)

Shift+Tab Unindent lines (only if text is selected)

Shift+F2 Go to the previous bookmark

Shift+Up arrow Extend the selection up one line

Table 50: Query Specific Shortcut Keys (continued)

Shortcut Keys Description

Teradata SQL Assistant for Microsoft Windows User Guide 179

Page 180: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Appendix B: Menus, Toolbars and ShortcutsQuery Specific Shortcut Keys

Shift+Down arrow Extend the selection down one line

Shift+Alt+arrow Select columns of text (see ‘Ctrl+Drag Mouse’ below)

Moves the cursor one character to the left

Moves the cursor one character to the right

Home Moves the cursor to the start of the current line

End Moves the cursor to the end of the current line

PageDown Moves down one page

PageUp Moves up one page

Ctrl+ Moves to the beginning of the current word

Ctrl+ Moves to the end of the current word

Ctrl+Home Moves to the start of the query

Ctrl+End Moves to the end of the query

Shift+ Extends the selection one character to the left

Shift+ Extends the selection one character to the right

Shift+Home Extends the selection to the start of the current line

Shift+End Extends the selection to the end of the current line

Shift+PageDown Extends the selection down one page

Shift+PageUp Extends the selection up one page

Ctrl+Shift+ Extends the selection to the start of the current word

Ctrl+Shift+ Extends the selection to the end of the current word

Ctrl+Shift+Home Extends the selection to the start of the query

Ctrl+Shift+End Extends the selection to the end of the query

Click Mouse Wheel

Selects the current word

Double Click Mouse Wheel

Selects the current line

Ctrl+Mouse Wheel Zooms the active window in and out

Table 50: Query Specific Shortcut Keys (continued)

Shortcut Keys Description

180 Teradata SQL Assistant for Microsoft Windows User Guide

Page 181: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Appendix B: Menus, Toolbars and ShortcutsWindow Control Shortcut Keys

Window Control Shortcut Keys

The following table lists the shortcut keys that handle Window and focus control.

Ctrl+Drag Mouse Select columns of text

Note: Requires a fixed pitch font to be useful.

Anything you type while the block is selected replaces the selected text on ALL selected lines

You remain in this column mode until you use the mouse again, or press Esc, or the arrow keys.

Table 50: Query Specific Shortcut Keys (continued)

Shortcut Keys Description

Table 51: Window Control Shortcut Keys

Shortcut Keys Description

Alt+F4 Closes the application

Ctrl+F4 Closes the current child window

Ctrl+F5 Restores the current child window to its previous size

Ctrl+F6 Moves focus to the next child window

Ctrl+F7 Moves the current child window

Ctrl+F8 Resizes the current child window

Ctrl+F9 Minimizes the current child window

Ctrl+F10 Maximizes the current child window

Ctrl+Tab Moves focus to the next child window

Ctrl+PageUp Displays the next Query/Answer tab

Ctrl+PageDn Displays the previous Query/Answer tab

Shift+F4 Tiles the child windows Horizontally

Shift+F5 Cascades the child windows

Shift+F6 Tiles the child windows Vertically

Alt+Space Displays the Control menu

Teradata SQL Assistant for Microsoft Windows User Guide 181

Page 182: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Appendix B: Menus, Toolbars and ShortcutsAnswer / History Specific Shortcut Keys

Answer / History Specific Shortcut Keys

The following table lists the shortcut keys that are specific to the Answer or History spreadsheets.

Alt Moves focus to the Menu bar (or back from Menu bar)

When the focus is on the Menu bar, the following keyboard shortcuts apply:

• : Moves focus to the next/previous menu or tool button

• Up arrow/down arrow: Moves focus to the next/previous menu item

• Ctrl+Tab: Moves focus to the next toolbar

• Down arrow: Drops down the list for a drop-down tool button

• Up arrow/down arrow: Moves through the list items

• Enter: Selects the current list item and leaves the toolbar

• Tab: Selects the current list item and moves to the next tool button

F4 Drops down the list (when focus is in a control with a dropdown button)

Table 51: Window Control Shortcut Keys (continued)

Shortcut Keys Description

Table 52: Answer / History specific Shortcut Keys

Shortcut Keys Description

Ctrl+Space Selects current column

Shift+Space Selects current row

Shift+arrow Extends selection in direction of arrow

Ctrl+ Moves the current column to the right (if moveable)

Ctrl+ Moves the current column to the left (if moveable)

Ctrl+Up arrow Moves the current column to the Group Bar (if visible)

182 Teradata SQL Assistant for Microsoft Windows User Guide

Page 183: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

APPENDIX C

Configuration Files

Much of the functionality of Teradata SQL Assistant is controlled by configuration files. In most cases these files are created automatically by the application during regular use. The files are written to \Users\<username>\AppData\Teradata\SQL Assistant on Windows 7 or \Documents and Settings\<username>\Application Data\Teradata\SQL Assistant otherwise.

When the application starts up it reads the configuration files from this location. If it does not find the file in this location, it checks the ‘All Users’ branch for a file of the same name. If it still does not find the file, it uses built-in application defaults.

The exception to this rule is Vendors.config, which is installed under the ‘All Users’ branch. The application never writes to it.

A customer may wish to install default configuration files as part of his or her own install process. The files can be installed in either location, but if the file already exists in the user’s own branch the application will never look at the one in the ‘All Users’ branch (except for Vendors.config).

The following sections describe the different configuration files.

UserOptions.config

This file contains all the options described on the Options dialog box. It also contains some additional ‘state’ information such as the size and position of the Main and Query Builder windows.

This file is rewritten each time the application is shut down.

When modifying this file for use as a default file in your custom install process, you must ensure that the <LastVersion> value is set correctly. This value should be set to a number that describes the version of SQL Assistant from which you are upgrading. It is used to control any upgrade processing that occurs. In general it is safe to simply set it to a value that is less than the new version you are installing.

However, if the value is set to less than 13.0, the application first reads the UserOptions.config file and looks in the registry to find the user’s options from SQL Assistant 12.0 (or earlier). Any options that exist for SQL Assistant 12.0 are overwritten by these registry values.

Note: Customized files for the install process should not contain Path names for History and so forth.

Teradata SQL Assistant for Microsoft Windows User Guide 183

Page 184: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Appendix C: Configuration FilesToolbars.config

Toolbars.config

This file describes the position and visibility of the Toolbars as well as which menu items appear on each menu, which tool buttons appear on each Toolbar, and the shortcut keys that are assigned to the menus and tool buttons.

This file is only created if the user moves or hides a toolbar, or uses the Tools > Customize menu.

DataSources.config

This file contains data source definitions for use by the Teradata.Net and Oracle.Net data providers. These definitions include connection information and (optionally) a list of Databases to be loaded into the Database Explorer Tree and the color bar to be displayed in the query window for this data source

This file is re-written each time the application is shut down.

Note: There may also be a DataSources.config file in the ‘All Users’ branch. That file contains system level data sources. The application never updates it.

DockMgr.config

This file describes the position and visibility of the Database Explorer Tree and the Favorites and Examples pane.

This file is re-written each time the application is shut down.

Vendors.config

This file describes how the application should work with different vendor databases. In general this file should only be modified if a customer wishes to support a new database that SQL Assistant does not currently support, or if the database settings cause SQL Assistant’s default settings to work incorrectly with that database.

The application never writes to this file.

Table 53: Properties Described by the Vendors.config File

Property Description

Key The first 5 characters of the DbmsName string returned by ODBCFor an ‘unknown’ vendor database this string appears in parens after the Data Source name in the Database Explorer Tree. It must be in uppercase.

184 Teradata SQL Assistant for Microsoft Windows User Guide

Page 185: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Appendix C: Configuration FilesVendors.config

Name The name to be displayed after the Data Source name in the Explorer Tree

SQLType The SQL dialect used by this vendor

This string is used to load the Language and Syntax Example files. It will normally be the same as Name, however there are exceptions. For example, Greenplum will use PostgreSQL.

DBType A numeric value used for database vendors that are known to SQL AssistantUse 0 for unknown, or a value >40 for new data sources.

Catalog The name of the catalog database. e.g. DBC for Teradata

This database is added to the Database Explorer Tree. The default is empty (No catalog).

HasRootDB Specifies whether the DBMS supports multiple Databases

The default is true.

RemoveCmt Specifies whether /* ... */ style comments must be removed from statements before they are submitted to the database

The default is false.

UpperName Specifies whether object names must be in upper case for use in catalog functions

The default is false.

UserIsDB Specifies whether a User can contain Tables, and so forth.

The default is false.

UseCatalog Uses the CatalogName parameter in ODBC catalog functions rather than the SchemaName parameter to specify the object container

The default is false.

Note: If the DBType is set to zero (Unknown), this value is overridden by the Use alternate schema... option on the DB Tree tab of Options.

UseDBPrefix Specifies whether object names should be prefixed by their container (Database) name when SQL Assistant generates SQL statements

The default is true.

ShowTable The SQL used to return a table definition

The default is empty.

ShowView The SQL used to return a view definition

The default is empty.

ShowProc The SQL used to return a procedure or function definition

The default is empty.

ChangePwd The SQL used to change the user’s password

The default is empty.

The Change Password menu is not available unless this is provided.

Table 53: Properties Described by the Vendors.config File (continued)

Property Description

Teradata SQL Assistant for Microsoft Windows User Guide 185

Page 186: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Appendix C: Configuration FilesVendors.config

Some of the strings used in this file may contain variables for which object names, or types, need to be substituted. The recognized variable names are described below:

In some cases, database compatibility may require changes to the vendor specific language file. For example, SQL Server allows the administrator to define the characters used to delimit an object name. By default the system uses the characters ‘[‘ and ‘]’ but it can be changed to use double quotes. In this case the SqlServer.lng file would have to be changed to match.

DDLPrefix Specifies whether the SQL used for a Show Definition function includes both prefix and body values. If the value is true then the SQL for all ShowXxxx properties must return 2 columns. The displayed DDL will be the concatenation of these 2 values. The default is false.

[db] The Database Name, or object container name (Catalog, Schema, and so forth)

[obj] The object name (Table, View, Procedure or Function)

[user] The current user name

[oldpwd] The current password for the user

[pwd] The new password you wish to set

[type] The object type (Procedure or Function)

[olddb] The current database name

This is required by some vendors if the object is not in the current database.

Table 53: Properties Described by the Vendors.config File (continued)

Property Description

186 Teradata SQL Assistant for Microsoft Windows User Guide

Page 187: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Glossary

AABORT In Teradata SQL, a statement that stops a transaction in progress and backs out changes to the database only if the conditional expression associated with the abort statement is true.

administrator A special user responsible for allocating resources to a community of users.

Ccolumn In the relational model of Teradata SQL, databases consist of one or more tables. In turn, each table consists of fields, organized into one or more columns by zero or more rows. All of the fields of a given column share the same attributes.

DDBA Database Administrator

database In Teradata SQL, a related set of tables that share a common space allocation and owner. This document uses the term “database” as the term for “table qualifier” (the object that contains data tables). This term varies depending on the database vendor, and may be referred to as “owner”, “schema” or “catalog” in the vendor's own documentation.

data definition In Teradata SQL, the statements and facilities that manipulate database structures and the Data Dictionary information kept about these structures. These statements include CREATE, DROP, ALTER, and MODIFY.

Data Definition Language (DDL) In Teradata SQL, the statements and facilities that manipulate database structures (such as CREATE, MODIFY, DROP, GRANT, REVOKE, and GIVE) and the dictionary information kept about those structures. In the typical, pre-relational data management system, data definition and data manipulation facilities are separated, and the data definition facilities are less flexible and more difficult to use than in a relational system.

Data Dictionary In the Teradata Database, the information automatically maintained about all tables, views, macros, databases, and users known to the Teradata Database system, including information about ownership, space allocation, accounting, and access right relationships between those objects. Data Dictionary information is updated automatically during the processing of Teradata SQL data definition statements, and is used parser to obtain information needed to process all Teradata SQL statements.

data manipulation In Teradata SQL, the statements and facilities that change the information content of the database. These statements include INSERT,UPDATE,and DELETE.

Teradata SQL Assistant for Microsoft Windows User Guide 187

Page 188: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Glossary

DDL Data Definition Language

delimiter In Teradata SQL, a punctuation mark or other special symbol that separates one clause in a Teradata SQL statement from another, or that separates one Teradata SQL statement from another.

DOS Disk Operating System

DNS Data Source Name

Ffailure Any condition that precludes complete processing of a Teradata SQL statement. Any failure aborts the current transaction.

field The basic unit of information stored in the database. A field is either null, or has a single numeric or string value. See also column, database, row, table.

HHTML Hypertext Markup Language

Jjoin In Teradata SQL, a select operation that combines information from two or more tables to produce a result.

Mmacro A set of Teradata SQL statements stored in the database and executed by a single EXECUTE statement. Each macro execution is implicitly treated as a transaction.

Nname In Teradata SQL, a word supplied from the user that refers to an object, such as a column, database, macro, table, user, or view.

null In Teradata SQL, the absence of a value for a field.

OOpen Database Connectivity (ODBC) Under ODBC, drivers are used to connect applications with databases. The Teradata ODBC driver processes ODBC calls from an application, but passes SQL requests to the database for processing.

owner In Teradata SQL, the user who has the ability to grant or revoke all privileges on a database to and from other users. By default, the creator of the database is the owner, but ownership can be transferred from one user to another with the GIVE statement.

188 Teradata SQL Assistant for Microsoft Windows User Guide

Page 189: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Glossary

Pparameter In Teradata SQL, a variable name in a macro for which an argument value is substituted when the macro is executed.

parser A program executing in a PE that translates Teradata SQL statements entered by a user into the steps that accomplish the user’s intensions.

parsing engine (PE) An instance (virtual processor) of the database management session control, parsing, and dispatching processes and their data context (caches).

QQuery Capture Database (QCD) A database of relational tables that store the steps of any query plan captured with the Query Capture Facility (QCF).

Query Capture Facility (QCF) Provides a method to capture and store the steps from any query plan in a set of predefined relational tables named the Query Capture Database (QCD).

query A Teradata SQL statement, particularly a SELECT statement.

Rrequest In host software, a message sent from an application program to the database.

result The information returned to the user to satisfy a request made of the database.

row In Teradata SQL, the fields, whether null or not, that represent one entry under each column in a table. The row is the smallest unit of information operated on by data manipulation statements.

Sseparator A character or group of characters that separates words and special symbols in Teradata SQL. Blanks and comments are the most common separators.

session In client software, a logical connection between an application program on a host and the database that permits the application program to send one request to and receive one response from the database at a time.

SQL See Structured Query Language

statement A request for processing that consists of a keyword verb, optional phrases, operands and is processed as a single entity.

stored procedure Teradata Version 2 Release 4 and later supports stored procedures. A stored procedure is a combination of SQL statements and control and conditional handling statements that provides an interface to the database.

structured query language (SQL) The abbreviation, SQL, is pronounced either see-kwell or as separate letters. SQL is a standardized query language for requesting information from a

Teradata SQL Assistant for Microsoft Windows User Guide 189

Page 190: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Glossary

database. The SQL language consists of a set of facilities for defining, manipulating, and controlling data in a relational database.

supervisory user In Data Dictionary, a user who has been delegated authority to further allocate database resources such as space and the ability to create, drop, and modify users within the overall user community.

Ttable In Teradata SQL, a set of one or more columns with zero or more rows that consist of fields of related information. See also database.

Teradata structured query language (Teradata SQL) A multipurpose database language used for defining, manipulating, controlling, loading, and archiving data.

Teradata SQL statement A statement in the Teradata SQL language that is processed through the Teradata Database.

title In Teradata SQL, a string used as a column heading in a report. By default, it is the column name, but a title can also be explicitly declared by a TITLE phrase.

transaction A set of Teradata SQL statements that is performed as a unit. Either all of the statements are executed normally or else any changes made during the transaction are backed out and the remainder of the statements in the transaction are not executed. The Teradata Database supports both ANSI and Teradata transaction semantics.

type An attribute of a column that specifies the representation of data values for fields in that column. Teradata SQL data types include numerics and strings.

Uuser In Teradata SQL, a database associated with a person who uses the Teradata Database. The database stores the person’s private information and accesses other Teradata Databases.

UTF-8 In simple terms, UTF-8 is an 8 bit encoding of 16 bit Unicode to achieve an international character representation.

In more technical terms, in UTF-8, characters are encoded using sequences of 1 to 6 octets. The only octet of a sequence of one has the higher-order bit set to 0, the remaining 7 bits are used to encode the character value. UTF-8 uses all bits of an octet, but has the quality of preserving the full US-ASCII range. The UTF-8 encoding of Unicode and UCS avoids the problems of fixed-length Unicode encodings because an ASCII file encoded in UTF is exactly same as the original ASCII file and all non-ASCII characters are guaranteed to have the most significant bit set (bit 0x80). This means that normal tools for text searching work as expected.

Vview In Teradata SQL, an alternate way of organizing and presenting information in the Teradata Database. A view, like a table, has rows and columns. However, the rows and columns

190 Teradata SQL Assistant for Microsoft Windows User Guide

Page 191: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Glossary

of a view are not directly stored in the Teradata Database, but are derived from the rows and columns of tables (or other views) whenever the view is referenced.

Teradata SQL Assistant for Microsoft Windows User Guide 191

Page 192: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Glossary

192 Teradata SQL Assistant for Microsoft Windows User Guide

Page 193: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Index

Aabort a query

how to 75toolbar button 168while executing 70

abort, defined 187account string, field 31Add Database command

Database Explorer Tree 46shortcut menu 47

Add to Favoritesshortcut menu 99

Add Totals commandshortcut menu 133toolbar button 167using 109

administrator, defined 187aggregate values, displaying 109alias name resolution, option 24Allow Close

toolbar button 171Answerset tab

deleting 111naming 111

Answerset Window 125Add Totals command

shortcut menu 132, 133toolbar button 167using 109

aggregate values, displaying 109cancelling print jobs 115changing

font 122, 133formatting 124

closing window(s) before submitting a query 117, 119column headers

freezing 106hiding 108moving 106saving answersets 113shortcut menu 134using to display Format Cells dialog box 125

columnshiding 134moving 134show all columns 134

width, adjusting 105wrap text 133

commands and descriptions 133Copy as HTML command 133Copy command

shortcut menu 133toolbar button 167

copying to Notepad 114decimal places

displaying 126format cells 133shortcut menu 133

delimiterbetween columns 97

displayingcolumn headers 108decimal places 126maximum number of answerset rows 119moving column headers 106row headers 109totals for numeric columns 109

Do Not Close command 134entering a file name 127exporting results 127file format types 112Find command

shortcut menu 133toolbar button 167

font, changing 122, 133Format Cells command

displaying decimal places 126formatting multiple rows or columns 125shortcut menu 133

formattinganswerset 124font 133

gridlinesshortcut menu 134toolbar button 171

listing, columns and tables 52matching an answerset with a SQL statement 108maximum answerset rows displayed 119naming 76, 111opening a saved answerset 111options 117, 119printing an answerset 114redirecting query output 127

Teradata SQL Assistant for Microsoft Windows User Guide 193

Page 194: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Index

row headershiding 108shortcut menu 134

row height 105rows, selecting all 107saving

answerset to a file 112multiple answersets 128

select all rows 107set font 133set title 76, 111shortcut menu 132sorting 115, 133viewing your results 105

arrange icons 37asynchronous query processing 70audible notification 100, 169

BBookmark toolbar button 169Browse command 43buttons See toolbar

CCascade Windows command

toolbar button 169using 37

Categories box 173CD-ROM images 6cells See Answerset Window, formattingchanging

Answerset Window font 122, 133Database Explorer Tree display 40location of history files 151menu behavior 175name displayed for a command 174Teradata database password 34

changing the text size 37Charting 122Clear Query toolbar button 167Close command 137color See Answerset Window, Format Cells commandColumn Headers command

freezing 106toolbar button 170using 108

columnsdefined 187freezing 106re-ordering 105

commands 38Answerset Window 133Database Explorer Tree 47

History Window 153Query Window 99

Commands box 173Comment text

toolbar button 170comments

adding to queries 82overview 62

compact history See History WindowConnect command

using 31, 32, 33connecting to a data source 30context menus See menuscontrolling

an export 129query execution 53, 65the Answerset Window 117, 119the History Window 145

convert tabs to spacestoolbar button 170

Copy as HTML commandAnswerset Window 133History Window 153

Copy commandAnswerset Window 133History Window 153Query Window 99, 100toolbar button 167

Copy to Clipboard command 88, 150Copy to Notepad command 81, 114, 150Create New Data Source dialog box 23custom syntax file

creating 90description 89

customizingmenus 172SQL statements 89, 90toolbars 172

Cut commandclipboard support 100shortcut menu 99toolbar button 167

Ddata definition, defined 187data dictionary, defined 187data manipulation, defined 187data source

connecting 31, 166defining 53, 57, 115description field 24name field 24reconnecting 34

194 Teradata SQL Assistant for Microsoft Windows User Guide

Page 195: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Index

Database Explorer TreeAdd Database command 47adding

databases 46object types 42

changing the display 40closing 40, 50collapsing branches 39deleting object types 42displaying object definitions 42Expand/Collapse command 39, 40, 47expanding branches 39object definitions, displaying 42opening 40, 50Quick Paste command 47Refresh Database command 47Remove Database command 46, 47Set Font command 168shortcut menu

commands 47displaying 47

Show Definition command 47toolbar button 168viewing object types 39

DBC database 39DBMS

password, changing 34time 136

decimal placesdisplaying 121, 126, 132specifying the number of 126, 133

defaultanswerset toolbar 165database field 25, 31directory paths 163directory, history files 151file paths 163preferences, settings, options 156query window toolbar 166toolbar 165

defining.Net Oracle Data Source 28.Net Teradata Data Source 25ODBC Data Source 23

delete blank linetoolbar button 170

Delete Toolbar dialog box 177delimited text

saving answerset as 112, 113, 149delimiters

defined 188defining null values 98import rules 97

directory

file storage 163Display SQL

command 108toolbar button 170

Do Not Closetoolbar button 171

DSNfile, system, user 23startup parameter 155

EEdit History dialog box See History WindowEdit menu

Add Totals command 133Copy command 99, 133, 150Cut command 99Find command 99, 133, 153Find Next command 99Format Query command 92, 100Paste command 99Replace command 100Sort command 133, 153Undo command 79

Editing Table Data 44elapsed 136errors

error column, History Window 136error messages 130syntax error in stored procedures, locating 36

Excelsaving answerset as 113, 149

Execute commandshortcut menu 99toolbar button 168using 70

Execute Parallel commandtoolbar button 168using 74

executinga query 73, 99statements in parallel 74, 168

Expand/Collapse commandDatabase Explorer Tree 39, 40, 47

EXPLAIN statement 115Explorer tree window 40export

controlling an export 129toolbar button 167

Export File dialog box 127Export Results command 127

Ffailure, defined 188

Teradata SQL Assistant for Microsoft Windows User Guide 195

Page 196: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Index

Favorites and Examples pane 50fetch time 136field, defined 188file DSN 23file format types 112File menu

Close command 137Copy to Notepad command 81, 114, 150Export Results command 127Import Data command 95, 98New Query command 70Open Answerset command 111Open Query command 81Print command 150Save Query As command 80

file paths 163files, importing 94filtering

History window 138, 143Find command

Answerset Window 133History Window 153Query Window 99toolbar button 167

Find Nextcommand 99toolbar button 167

Find Previoustoolbar button 167

float columns 121font

Answerset Window 122, 133History Window 153Query Window 100

Font dialog box 100, 133, 153Format Cells

toolbar button 171Format Query

command 100toolbar button 167

formattingSee Answerset WindowSee Query Window

Freeze Columntoolbar button 171

freezing columns 106function keys 38

Ggeneral information about Teradata 6Generating SQL for use with a Table or View 43Grid Lines

command 118

shortcut menu 134toolbar button 171

Hheader

skipping in imported files 94help

online help 38, 169Help menu

About SQL Assistant command 38Help Topics command 38Query Builder command 88

history filterfilter 138, 143

history recordadding or changing a note 148

history rowsselecting 141

History Windowadding notes 147cancelling print jobs 151closing 137column

headers 141names and descriptions 136

commands and descriptions 153compacting history 147Copy as HTML command 153Copy command 153, 167copying history window

to Clipboard 150to Notepad 150

default directoryhistory files 151

displaying 137Edit History dialog box

displaying 147editing records 146, 147navigating 147shortcut menu 153view error (result) messages 147

error code 136file format types 148filter 153find command 153font, changing 153formatting font 153hiding 137history files, default directory 151navigating 138notes 147options 145overview 135

196 Teradata SQL Assistant for Microsoft Windows User Guide

Page 197: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Index

preventing queries from being saved 78printing

cancelling print jobs 151the history table 150

results message 147rows, selecting all 141saving history records 148select all rows 141sorting 141, 153storing history files 151

hot keys 38HTML

saving answerset as 113, 149

IImport Data command 95, 98importing data

defining a null value 98exiting from import mode 95getting multiple answersets from one query 98how to 95import rules 97overview 94toolbar button 167types of import operations 95

Indenttoolbar button 170

Information Products Publishing Library 6insert date command 100insert into query 88integrated security, option 24, 31

Jjoin, defined 188

Kkey features of Teradata SQL Assistant 22

Llength 136line number, locating syntax errors 36List Columns

dialog box 52list columns in a table or view 52toolbar button 169

List Tablesdialog box 52list tables in the database 52toolbar button 169

listing, columns and tables 52Lowercase

toolbar button 170

MMacro command

using 78macro, defined 188main window 35matching answerset with SQL statement 108Maximum number of answer rows to display text box 119mechanism 24mechanism and parameter 31menu bar 35

resetting default menu bar 176menus

adding breaks between commands 174adding commands to 172Answerset shortcut menu 132changing command names 174changing menu behavior 175customizing 172Database Explorer Tree shortcut menu 47moving commands 174Query Window shortcut menu 99removing breaks between commands 174removing commands 173resetting default menu bar 176shortcut 38showing recently used commands 175

Menus show recently used commands first check box 175merge cells

toolbar button 171Microsoft Excel

saving answerset as 113, 149Minimize on Execution

command 100toolbar button 169

Move Columnstoolbar button 171

multiple data sourcesconnecting 33

multiple queries, allowing 62multistatement queries 75

Nname, defined 188naming answersets 76, 111New Query

toolbar button 166New Query command 70New Toolbar dialog box 176next bookmark

toolbar button 170Next SQL command

Teradata SQL Assistant for Microsoft Windows User Guide 197

Page 198: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Index

toolbar button 168using 78, 141

Notepadcopy history window to 150copying answerset to 114toolbar button 166

notescolumn name, History Window 136Edit History dialog box 147prompt for notes

shortcut menu 100toolbar button 169

null, defined 188

OODBC

connecting to data source 30, 66data source administrator 23, 25defined 188defining a data source 23disconnecting from data source 30, 66driver 25Driver Setup for Teradata Database dialog box 24passwords 34

Open Answerset command 111Open Query

toolbar button 166Open Query command 81Options, file paths 163ordering publications 6owner, defined 188

Ppage setup 56parameter 24parameter and mechanism 31Parameterized Queries 64parameterized queries

named parameters 64parameters

defined 189startup 155

parser, defined 189parsing engine (PE), defined 189password

changing the Teradata Database 34ODBC Driver Setup dialog box 24

Paste command 99, 101toolbar button 167

Play macrotoolbar button 170

preferences 156Previous bookmark 170

Previous SQL commandtoolbar button 168using 77, 140

Print command 167print preview 57, 114

command 167toolbar button 167

printingan answerset 114cancelling print jobs 115the history table 150toolbar button 167

product version numbers 3product-related information 6Prompt for Notes

button 169shortcut 100toolbar button 169

publications related to this release 6

QQCD 86queries

aborting See aborting a queryadding comments to 62, 82adding notes 100, 136, 169asynchronous processing 70cancelling See aborting a querycontrolling 53, 65copying

Clipboard support 100queries from History window 77, 140shortcut menu 99to Notepad 81toolbar button 167

creating 87defined 189disable saving 78displaying a visual EXPLAIN 86entering 70executing

a query 73, 99, 168statements in parallel 74

Format Query commandshortcut menu 100toolbar button 167using 92

multiple, allowing 62multistatement query 75opening from a file 81, 166replace 100saving 80scheduling for later execution 91

198 Teradata SQL Assistant for Microsoft Windows User Guide

Page 199: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Index

submitting 75Query Builder

future use 89overview 87shortcut menu 99toolbar button 169

Query Capture Database 86Query Note dialog box 147, 148query tab

deleting 76naming 76

Query Windowclearing for new query 166commands and descriptions 99Copy command 99, 100, 167Cut command 99, 100, 167displaying a visual EXPLAIN 86Find command, shortcut menu 99Find Next command, shortcut menu 99finding or replacing text 84, 85font, changing 100Format Query command 100formatting

a query 92changing font 100indentation information 92setting formatting options 92SQL keywords 67

functions 100insert date command 100minimize on execution 100options 65, 129, 130, 131overview 61Paste command

Clipboard support 101shortcut menu 99

record or execute a macro 78Redo command

Clipboard support 101Replace command

shortcut menu 100toolbar button 167

Select All command 100selecting text using the margin 63shortcut menu 99splitting into two windows 63toggling bookmarks using the margin 63toolbar, displaying 62undo changes 79Undo command

Clipboard support 101Visual Explain command 86

Quick Paste commandshortcut menu 47

using reconnecting to a data source 41

RReconnect command

using 34reconnecting to a data source 34Record macro

toolbar button 170redirecting query output 127Redo command 101

toolbar button 167Refresh Database command

Database Explorer Tree 47shortcut menu 47

registry, system 156release definition 5Remove all bookmarks

toolbar button 170Remove Database command

Database Explorer Tree 46, 47Rename Toolbar dialog box 177Replace command

inserting a statement or procedure 88shortcut menu 100toolbar button 167

replace query 88request, defined 189Reset my usage data button 175Reset Toolbar dialog box 176, 177result, defined 189results grid

finding a text string 142Row Headers

command 109toolbar button 171

row, defined 189rows 136run date 136

SSave Query As command 80saving

a query 80an answerset 112multiple answersets 128

Schedule commandtoolbar button 168using 92

scheduling queries for later execution 91ScreenTips 176Select All command

Answerset Window 107History Window 141

Teradata SQL Assistant for Microsoft Windows User Guide 199

Page 200: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Index

Query Window 100separator, defined 189seq (sequence) 136session, defined 189Set Font command

Answerset Window 133History Window 153Query Window 100toolbar button 168

Set repeat counttoolbar button 170

Set Title commandmenu command 173using 76, 111

setting database tree preferences 48shortcut keys 38shortcut menus 38

Answerset Window 132Database Explorer Tree 47Query Window 99

Show Definition commandDatabase Explorer Tree 47

Show full menus after a short delay check box 175Show History command 137Show ScreenTips on toolbars check box 176Show whitespace

toolbar button 170Sort command

answerset 115history 141, 153shortcut menu 133, 153toolbar button 168

source 136SQL

defined 189statement 136type 136

startup parameters 155statement

creating multi-statement queries 62, 63creating statements 62, 63DDL 62, 94defined 189DML 62, 94EXPLAIN 115SQL 62, 94

status bar 35stmts 136stmts type 136stored procedures

creating 89defined 189locating syntax errors 36

submitting multiple statements 74

supervisory user, defined 190syntax

errors 36SQL syntax examples 87using Query Builder 88

systemDSN 23registry 156

Ttabbed windows 36tab-delimited

saving answerset as 112, 149table, defined 190Teradata Database

aborting a query in progress 75columns of the History Window 136dialog box 24execute in parallel 74import rules 97ODBC

data source 23driver 25

password, changing 34SQL statement, defined 190SQL, defined 190submitting queries 70

Teradata Database Connect... dialog box 31Teradata Query Scheduler

scheduling queries for later execution 91toolbar button 168

Teradata SQL Assistantkey features 22minimizing

on execution 100starting 30

Teradata Visual Explain commandtoolbar button 168using 86

text, in the Query Windowfinding or replacing 84, 85

Tile Windows commandtoolbar button 169using 37

title, defined 190tool tips See ScreenTipstoolbar

adding 176breaks between commands 174commands 172

answerset 165buttons and descriptions 166customizing 172

200 Teradata SQL Assistant for Microsoft Windows User Guide

Page 201: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Index

default 165hiding 176moving commands 174overview 35query window 62, 166removing 176

breaks between commands 174commands 173

renaming 176resetting 176ScreenTips 176showing/hiding ScreenTips 176

Tools menuChange Password command 34Compact History command 147Customize command 173Define Data Source command 23Edit History command 147Execute command 73Execute Parallel command 74Explain command 86List Columns command 52List Tables command 52Options command 53, 54, 65, 118, 119, 129, 130, 131, 145Reconnect command 34Schedule command 92Visual Explain command 86

totals, add 132, 133Transactions

defined 190Using 73

troubleshooting 38type, defined 190

UUndo command 101

toolbar button 167using 79

unicode datadisplaying in the Answer window 57exporting 57importing 58support for 57

Unindenttoolbar button 170

Uppercasetoolbar button 170

userdefined 190DSN 23ID 136

username field 24UTF-8

defined 190support 57

Vversion numbers 3View menu

Explorer Tree 40, 50Go To Explorer 40, 51Next SQL 78, 141Previous SQL 77, 140Set Font command 100Show History 137Status Bar 35Toolbar 166

view, defined 190Visual Explain command

toolbar button 168using 86

visually impairedchanging the color scheme 58changing the text size 58support for screen readers 58

Wwildcard characters with history filter 140Window menu

Arrange Icons command 37Cascade command 37Set Title command 111Tile command 37

windowscascade 169tabbed 36tile 169

Working with the EditTable dialog 44Wrap Text

toolbar button 171

XXML

saving answerset as 113, 150

Teradata SQL Assistant for Microsoft Windows User Guide 201

Page 202: Teradata SQL Assistant for Microsoft Windows User Guidedbmanagement.info/Books/MIX/teradata_sql_assitant... · Teradata SQL Assistant for Microsoft Windows User Guide 3 Preface Purpose

Index

202 Teradata SQL Assistant for Microsoft Windows User Guide