Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Microsoft Jet Database Engine wikipedia , lookup
Microsoft SQL Server wikipedia , lookup
Entity–attribute–value model wikipedia , lookup
Open Database Connectivity wikipedia , lookup
Functional Database Model wikipedia , lookup
Extensible Storage Engine wikipedia , lookup
Clusterpoint wikipedia , lookup
What would you do if you knew?™ Teradata Studio Express User Guide Release 15.12 B035-2042-086K August 2016 The product or products described in this book are licensed products of Teradata Corporation or its affiliates. Teradata, Active Data Warehousing, Active Enterprise Intelligence, Applications-Within, Aprimo Marketing Studio, Aster, BYNET, Claraview, DecisionCast, Gridscale, MyCommerce, QueryGrid, SQL-MapReduce, Teradata Decision Experts, "Teradata Labs" logo, Teradata ServiceConnect, 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. Apache, Apache Avro, Apache Hadoop, Apache Hive, Hadoop, and the yellow elephant logo are either registered trademarks or trademarks of the Apache Software Foundation in the United States and/or other countries. Apple, Mac, and OS X all are registered trademarks of Apple Inc. Axeda is a registered trademark of Axeda Corporation. Axeda Agents, Axeda Applications, Axeda Policy Manager, Axeda Enterprise, Axeda Access, Axeda Software Management, Axeda Service, Axeda ServiceLink, and Firewall-Friendly are trademarks and Maximum Results and Maximum Support are servicemarks of Axeda Corporation. Data Domain, 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. Hortonworks, the Hortonworks logo and other Hortonworks trademarks are trademarks of Hortonworks Inc. in the United States and other countries. 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 Dell 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. Quantum and the Quantum logo are trademarks of Quantum Corporation, registered in the U.S.A. and other countries. Red Hat is a trademark of Red Hat, Inc., registered in the U.S. and other countries. Used under license. SAP is the trademark or registered trademark of SAP AG in Germany and in several other countries. SAS and SAS/C are trademarks or registered trademarks of SAS Institute Inc. Simba, the Simba logo, SimbaEngine, SimbaEngine C/S, SimbaExpress and SimbaLib are registered trademarks of Simba Technologies 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 e-mail: [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 © 2016 by Teradata. All Rights Reserved. Table of Contents Preface...................................................................................................................................................................9 Purpose............................................................................................................................................................................ 9 Audience..........................................................................................................................................................................9 Revision History.............................................................................................................................................................9 Additional Information.................................................................................................................................................9 Product Safety Information........................................................................................................................................ 10 Chapter 1: Getting Started With Studio Express....................................................................... 11 About Teradata Studio Express..................................................................................................................................11 Launching the Workbench......................................................................................................................................... 11 Workbench................................................................................................................................................................... 11 Customizing the Display.................................................................................................................................12 Toolbars.............................................................................................................................................................12 Preferences........................................................................................................................................................ 12 Logging Preferences.............................................................................................................................14 Teradata Datatools Preferences..........................................................................................................14 JDBC Connection Properties............................................................................................................. 14 Views..............................................................................................................................................................................14 Opening Views................................................................................................................................................. 15 Moving View Panels........................................................................................................................................ 15 Data Source Explorer...................................................................................................................................................15 Data Source Explorer Load Preferences........................................................................................................15 Setting Data Source Explorer Load Preferences.......................................................................................... 17 Setting Root of Data Source Explorer Display............................................................................................. 18 Chapter 2: Database Connectivity.................................................................................................................. 19 About Connection Profiles......................................................................................................................................... 19 Maximum Connections per Profile Preference....................................................................................................... 20 Teradata Database Connectivity................................................................................................................................ 20 Creating a Teradata Connection Profile....................................................................................................... 20 Kerberos Authentication.....................................................................................................................21 Adding a New Teradata Driver Definition...................................................................................................21 Adding a JDBC Property.................................................................................................................................22 Editing JDBC Connection Properties........................................................................................................... 22 Database Cache................................................................................................................................................ 23 QueryBand Preferences...................................................................................................................................24 Aster Database Connectivity...................................................................................................................................... 24 Teradata Studio Express User Guide, Release 15.12 3 Table of Contents Creating an Aster Database Connection Profile..........................................................................................24 Specify a Driver and Connection Details......................................................................................................25 Aster Database Connection Properties......................................................................................................... 27 Connecting to an Aster Database.................................................................................................................. 29 Disconnecting From Aster Database.............................................................................................................29 Deleting an Aster Connection Profile........................................................................................................... 29 Adding and Editing JDBC Connection Properties..................................................................................... 29 Changing the Aster User Password............................................................................................................... 30 Adding an Aster Database Driver Definition...............................................................................................30 New JDBC Property.............................................................................................................................31 Add a JDBC Property.......................................................................................................................... 31 About Caching Aster Schemas.......................................................................................................................31 Caching Aster Schemas....................................................................................................................... 32 Schema Cache Properties....................................................................................................................32 Editing Aster Cache Schema Properties........................................................................................... 33 About Refreshing Schema Cache.......................................................................................................33 Deleting Aster Cache Files.................................................................................................................. 34 Hadoop Connectivity.................................................................................................................................................. 34 Creating a Hadoop Generic System Connection Profile............................................................................34 Hadoop Cloudera Connection Profiles.........................................................................................................35 Creating Hadoop Cloudera Connection Profiles............................................................................ 35 Hadoop Hortonworks Connection Profiles................................................................................................. 37 Creating Hadoop Hortonworks Connection Profiles.....................................................................37 Oracle, DB2, and SQL Server Connections.............................................................................................................. 39 Chapter 3: Teradata Data Lab...............................................................................................................................41 About Data Lab............................................................................................................................................................ 41 About the Data Lab View............................................................................................................................................41 Opening the Data Lab View........................................................................................................................... 42 Copying Tables to Data Labs..........................................................................................................................43 Data Lab Copy Wizard................................................................................................................................................43 About the Data Lab Copy Wizard................................................................................................................. 43 About Copy Table............................................................................................................................................ 44 About Filter Table............................................................................................................................................ 46 About SQL Preview Filter Table.................................................................................................................... 47 Chapter 4: Query Development.......................................................................................................................... 49 Data Tools for Query Development.......................................................................................................................... 49 Teradata SQL Editor....................................................................................................................................................49 About the SQL Editor......................................................................................................................................49 Using the SQL File Editor................................................................................................................... 50 Drag and Drop into SQL Editor.........................................................................................................51 SQL Editor Preferences....................................................................................................................... 51 SQL Editor Toolbar..............................................................................................................................54 SQL Handling................................................................................................................................................... 55 BLOB Disposition................................................................................................................................ 56 4 Teradata Studio Express User Guide, Release 15.12 Table of Contents CLOB Disposition................................................................................................................................57 LOB Disposition...................................................................................................................................57 Setting SQL Handling Preferences.................................................................................................... 58 Execute SQL......................................................................................................................................................59 Running SQL........................................................................................................................................ 59 Format SQL Command...................................................................................................................................60 Set Connection Information...........................................................................................................................60 SQL Editor Templates..................................................................................................................................... 60 Retrieving Table Rows using a SELECT Template..........................................................................60 Inserting Table Rows using an INSERT Template..........................................................................61 Inserting Table Rows using Parameterized Queries....................................................................... 61 Updating Table Rows using an UPDATE Template.......................................................................63 Deleting Table Rows using a DELETE Template............................................................................ 63 Inserting Aster Analytical Functions.................................................................................................64 About Teradata SQL Query Builder..........................................................................................................................65 Result Set Viewer..........................................................................................................................................................66 Result Set Viewer Preferences........................................................................................................................ 69 Setting Result Set Viewer Preferences............................................................................................... 70 Results Preferences...............................................................................................................................72 Formatting the Foreground in Selected Cells.................................................................................. 73 Formatting the Background in Selected Cells.................................................................................. 73 SQL History View........................................................................................................................................................ 73 SQL History Form............................................................................................................................................73 About SQL History Form............................................................................................................................... 75 Toolbar for SQL History................................................................................................................................. 76 Cleanup History............................................................................................................................................... 77 Import History................................................................................................................................................. 77 Export History.................................................................................................................................................. 78 Filtering with Data Filter.............................................................................................................................................78 History Preferences..........................................................................................................................................79 Database Objects Search............................................................................................................................................. 80 Find Object........................................................................................................................................................80 Finding Objects.................................................................................................................................... 81 Advanced Find Objects................................................................................................................................... 82 Find Results.......................................................................................................................................................83 Showing Table Row Counts....................................................................................................................................... 84 Chapter 5: Table Data Development........................................................................................................... 85 About the Table Data Editor...................................................................................................................................... 85 Table Data Editor......................................................................................................................................................... 86 Toolbar.............................................................................................................................................................. 87 About Editing Large Data and Objects......................................................................................................... 89 About Paging Large Tables.............................................................................................................................89 Data Filter..........................................................................................................................................................89 Opening the Table Data Editor...................................................................................................................... 90 Table Data Editor Preferences........................................................................................................................90 Setting Table Data Editor Preferences.............................................................................................. 92 Table Data Editing....................................................................................................................................................... 92 Teradata Studio Express User Guide, Release 15.12 5 Table of Contents About Editing Table Data............................................................................................................................... 92 Editing Table Data........................................................................................................................................... 92 Inserting Table Data........................................................................................................................................ 93 Displaying Column Data by Value................................................................................................................93 Deleting Table Rows........................................................................................................................................ 94 Deleting Data from Cells.................................................................................................................................94 Reverting Edits................................................................................................................................................. 94 Finding and Replacing Data........................................................................................................................... 94 Find Replace..........................................................................................................................................95 Selecting to Filter by Edits...............................................................................................................................96 Viewing SQL Preview for Data Updates.......................................................................................................96 Large Data and Objects Editing................................................................................................................................. 96 About the Blob Editor..................................................................................................................................... 96 Blob Editor............................................................................................................................................ 98 Opening the Blob Editor..................................................................................................................... 98 Editing BLOB Data.............................................................................................................................. 99 About the Clob Editor..................................................................................................................................... 99 Clob Editor..........................................................................................................................................101 Opening the Clob Editor...................................................................................................................101 Editing CLOB Data............................................................................................................................102 About the Large Binary Editor.....................................................................................................................102 Opening the Large Binary Editor.....................................................................................................103 Large Binary Editor............................................................................................................................104 Editing Large Binary Data................................................................................................................ 105 About the Large Text Editor.........................................................................................................................105 Large Text Editor............................................................................................................................... 107 Opening the Large Text Editor........................................................................................................ 107 Editing Large Text Data.................................................................................................................... 108 About the XML Data Type Editor............................................................................................................... 108 XML Editor......................................................................................................................................... 110 Opening the XML Editor.................................................................................................................. 110 Editing XML Data..............................................................................................................................111 Table Data Filtering................................................................................................................................................... 111 About Filtering Table Data...........................................................................................................................111 About the Data Filter.....................................................................................................................................112 Exporting Table Data................................................................................................................................................ 115 Chapter 6: Data Import and Export............................................................................................................117 Importing Data Into a Volatile Table......................................................................................................................117 Import and Load External Data (Teradata, Aster)................................................................................................118 About the Load Data Wizard (Teradata, Aster)........................................................................................ 118 Load Data Wizard (Teradata, Aster)...............................................................................................119 Loading Table Data from a File (Teradata, Aster)........................................................................ 121 About the Load Data Wizard and JDBC.................................................................................................... 122 Import and Load External Data (Hadoop).............................................................................................................122 About the Load Data Wizard (Hadoop).....................................................................................................122 Load Data Wizard (Hadoop)............................................................................................................123 Loading Table Data from a File (Hadoop)..................................................................................... 124 6 Teradata Studio Express User Guide, Release 15.12 Table of Contents About Smart Load Wizard (Teradata, Aster)........................................................................................................ 125 Creating Tables with Smart Load (Teradata, Aster)................................................................................. 126 Editing Column Data Types (Teradata, Aster)..........................................................................................128 Smart Load Data Types for Teradata Tables..............................................................................................129 Smart Load Data Types for Aster Tables.................................................................................................... 130 About Smart Load Wizard (Hadoop)..................................................................................................................... 131 Creating Tables with Smart Load (Hadoop).............................................................................................. 132 Editing Column Data Types (Hadoop).......................................................................................................134 Smart Load Data Types for Hadoop Tables............................................................................................... 134 Export External Data................................................................................................................................................. 135 About the Export Data Wizard.................................................................................................................... 135 Exporting Table Data to an External File................................................................................................... 136 Transfer Progress View............................................................................................................................................. 136 About the Transfer Progress View.............................................................................................................. 136 Transfer Details.............................................................................................................................................. 137 Job Details....................................................................................................................................................... 138 Transfer History View...............................................................................................................................................138 About the Transfer History View................................................................................................................ 138 Transfer History Filter.................................................................................................................................. 140 Sort................................................................................................................................................................... 141 Chapter 7: Troubleshooting................................................................................................................................... 143 Troubleshooting.........................................................................................................................................................143 Teradata Studio Express User Guide, Release 15.12 7 Table of Contents 8 Teradata Studio Express User Guide, Release 15.12 Preface Purpose The purpose of this guide is allow SQL developers and database administrators to test and use the Teradata Studio Express development environment. Audience This guide is intended for SQL developers and database administrators of Teradata Database, Teradata Aster Database, and Hadoop systems. Revision History Date Description August 2016 Release 15.12 Additional Information Additional information is available at Teradata Developer Exchange. Related Links URL Description https://tays.teradata.com Use Teradata At Your Service to access Orange Books, technical alerts, and knowledge repositories, view and join forums, and download software packages. www.teradata.com External site for product, service, resource, support, and other customer information. Related Documents Title Publication ID Teradata Studio, Studio Express, and Plug-in for Eclipse Installation Guide B035-2037 Customer Education Teradata Customer Education delivers training for your global workforce, including scheduled public courses, customized on-site training, and web-based training. For information about the classes, schedules, and the Teradata Certification Program, go to www.teradata.com/TEN/. Teradata Studio Express User Guide, Release 15.12 9 Preface Product Safety Information Product Safety Information This document may contain information addressing product safety practices related to data or property damage, identified by the word Notice. A notice indicates a situation which, if not avoided, could result in damage to property, such as equipment or data, but not related to personal injury. Example Notice: Improper use of the Reconfiguration utility can result in data loss. 10 Teradata Studio Express User Guide, Release 15.12 CHAPTER 1 Getting Started With Studio Express About Teradata Studio Express Begin using Teradata Studio Express by creating a Connection Profiles for your database. Then in the Data Source Explorer open the Connection Profile where you can browse the Databases, Indexes, Macros, Tables, Stored Procedures, User-defined Functions, User-defined Types, and Views folders to discover the database objects. Note: The highest level in the tree is the database server node, indicated by the database name provided in the Connection Profile. If no database name was provided, the default database name 'DBC' is used. Clicking on an object in the Data Source Explorer displays the object in the Object Viewer. An SQL Editor is provided for you to start entering your SQL statements. Launching the Workbench Prerequisite This procedure assumes you have installed Teradata Studio Express. See Teradata Studio, Studio Express, and Plug-in for Eclipse Installation Guide for installation instructions. 1. To launch Teradata Studio Express: Operating System To Launch Linux a. Update your path variable to include the Teradata Studio Express directory. b. Execute TeradataStudioExpress. Mac Execute (or double-click) Teradata Studio Express in the TeradataStudio directory. Windows Double-click the Teradata Studio Express desktop icon shortcut. Workbench Teradata Studio Express User Guide, Release 15.12 11 Chapter 1: Getting Started With Studio Express Workbench Customizing the Display The initial display for Teradata Studio Express consists of: • Data Source Explorer • Project Explorer • Teradata Result Set Viewer There is an additional view, the SQL Editor , that is displayed when an SQL file is opened. You can move the view panels around the display area, as well as move sections of the toolbar. You can also remove a view panel by clicking the X on the view tab. A view can be re-displayed by selecting the view from the Windows > Show View menu. To reset the perspective back to the default settings, select Window > Reset Perspective from the top-most toolbar. Toolbars Each view contains a toolbar that gives you quick access to functions and dialogs for creating, modifying, and administering database objects. Preferences Modify preferences by selecting Window > Preferences. In the Preferences window, you can filter the information or navigate to the preference. Changes to preferences are stored within your workspace. Data Management Preferences Preference Description Connectivity Configures the connectivity Driver Definitions by adding, editing, removing, or copying driver definitions Label Decorations Specifies the display format for columns in the Data Source Explorer SQL Development Option Description General Specifies settings for database development SQL Editor Offers options for the SQL Editor for code assist, connection behavior for SQL files, syntax colors, and SQL templates SQL Query Builder Omits the current database/schema from the generated SQL statements of the SQL Query Builder SQL Results View Options Offers options for displaying the results of SQL statements General Preferences Preference Description Appearance Customizes the display appearance by offering options for theme, color, font, and label preferences Table continued on next page. 12 Teradata Studio Express User Guide, Release 15.12 Chapter 1: Getting Started With Studio Express Workbench Preference Description Compare/Patch Customizes the display when comparing text files Content Types Enables you to associate editors with file types Editors Customizes editor behaviors and functions and adds or removes the editors and file types available in the Content Types preferences Globalization Customizes global settings for Unicode and text/graphic support Keys Customizes the keyboard bindings Workspace Changes the text file encoding for the workspace Help Preferences Preference Description Content Customizes the display of the help screens as well as configuring remote help content. Teradata Datatools Preferences Preference Description Teradata Datatools Sets query and size preferences for all Teradata datatools Connection Options Sets connection preferences for connection profiles. Preferences include maximum connections per profile. For Teradata connections, queryband options allow you to specify user and metadata queryband settings, as well as fastload/export options. In addition, you can specify default JDBC Connection Properties for Teradata and Aster connections. Data Source Explorer Load Sets preferences in the Data Source Explorer for display of database and user object hierarchy and for load settings that determine which databases and user objects to load Data Utilities Specifies the root directory location and thresholds for disk cache and maximum rows allowed for COMMIT transactions Dependencies Sets preferences for accessing the Meta Data Services web service Export Sets the preference to launch a native editor and customizes export options. Select Write SQL and Result Status to the Export File to include the SQL and result status when exporting. History Sets the exclude options for the History database, maximum number of rows to display, and which columns to show in the SQL History View Logging Specifies your preferences for logging messages New Profile Connection Types Sets which types of connection profiles to show as options in the New Connection Profile dialog Result Set Viewer Sets preferences for Teradata Result Set Viewer. SQL Formatter Sets preference options for the SQL Formatter. SQL Handling Sets handling preferences for SQL result sets and options for drag-and-drop and autoconnect functions. You can also specify the LOB sizes for handling large values for Teradata and Aster, and customize success and failure notification as sounds during SQL execution. Table Data Editor Sets preferences for selection color options, filter thresholds, and editor display and copy/paste options. Teradata Studio Express User Guide, Release 15.12 13 Chapter 1: Getting Started With Studio Express Views Logging Preferences Teradata error log messages are sent to teradata.log which is located in workspacelocation/.metatdata/Teradata. They are also sent to the Teradata Log Console. You can control the logging content in the log file and the Console independently. The Console is not a view of the log file. Teradata Datatools Preferences The Teradata Datatools Preference dialog lets you configure options that control the use of views to obtain metadata information and to set the byte increments for display of size metrics. The application uses system views to obtain information for its displays, such as the list of databases. Typically the views are available in two forms: the V view and a VX view variant. Depending on your permissions and how your database is set up, you may only be able to access the information through one form. Use the Teradata Datatools Preference to select the V, VX, or a Custom View to be used when loading the metadata for various objects. If you select Custom Option, you must provide the fully-qualified name for a table or view. Also, the table or view must provide the exact same column names and data types as the associated DBC view. For example, if you are providing a custom view for the Databases list, you must provide a fully-qualified name for a table or view that contains same columns as DBC.DatabasesVX view. At Size Preference, chose whether KB, MB, and GB increments are in multiples of 1000 or 1024. JDBC Connection Properties Under Preferences, under Connection Options, use the JDBC Connection Properties to define your default JDBC connections. For example, enter TMODE=TERA to set the system level default to Teradata or TMODE=ANSI to set the system level default to ANSI. Views The system provides multiple views and tools that allow you to explore, discover, and manage Teradatasupported databases, to develop and execute SQL queries, and to transfer data between databases. Many of the views appear as tabbed panes in the perspective. Not every view applies to every perspective. This table shows the more commonly-used views in the system. Some views are explained in more detail below. View Description Data Source Explorer Contains the database object tree display in the Query Development and Data Transfer perspectives. You can create Connection Profiles to your Teradata Database systems and interact with database objects. Project Explorer Provides a hierarchical view of the Projects and their resource files. You can select SQL files for editing or create new SQL files. Details/Forms Displays specific details for the selected database object and allows them to be created or modified Table continued on next page. 14 Teradata Studio Express User Guide, Release 15.12 Chapter 1: Getting Started With Studio Express Data Source Explorer View Description Data Lab Provides access to your tables from a Teradata Data Lab. SQL Editor Displays when an SQL file is opened. Initially, the SQL Editor is opened to provide an area to enter SQL statements. Double-clicking a file in the Project Explorer causes the file to be opened in the SQL Editor view. Teradata SQL History Maintains a list of SQL queries issued from the SQL editor, allowing you to re-execute them. Teradata Result Set Viewer Displays the result set returned by SQL queries issued from the SQL Editor view. Individual Result Set tabs are created for each result set. If a CALL to a stored procedure that has OUT or INOUT parameters is run, a tab is shown in the Result Set Viewer that contains the output values of the parameters. Transfer History Provides a display of the Data Transfer History information in the database. When a data transfer completes, an entry is placed in the Transfer History. Transfer Progress Displays a list of executing data transfer jobs and their status. Opening Views 1. In the main menu bar, select Window > Show View. 2. Select a view in the list or click Other to display additional views in the Show View dialog. Your current perspective determines which views you can select. The view you select displays in the workbench. Moving View Panels You can customize the look and feel of the interface by moving view panels within the display window. Move a view by dragging it to a new location. You can also drag the view outside the display area, detaching it. Data Source Explorer The Data Source Explorer supports SQl development and execution, as well as data transfers. The Data Source Explorer is available in the Query Development perspective and Data Transfer perspective. Data Source Explorer Load Preferences The Data Source Explorer Load Preferences enable you to configure your preference settings for loading database and user objects and to determine what folders are shown in the Data Source Explorer hierarchical tree display. You can set preferences to: • Load databases and users: ∘ All databases and all users ∘ Load only databases and certain users Teradata Studio Express User Guide, Release 15.12 15 Chapter 1: Getting Started With Studio Express Data Source Explorer ∘ Load all databases and users with PermSpace configured • Configure the hierarchical display to show: ∘ All databases and all users ∘ Only certain folders you specify • Whether to load object details for: ∘ Table space and journals ∘ Column data types in views. • Whether filters created for folders in the Data Source Explorer should be case-insensitive. The default is for filters to be case-sensitive. Check the option if you want filters to be case-insensitive. What to Load Use radio buttons in this section to set preferences for which objects you want loaded to the Data Source Explorer view. Option Description All Databases and Users Loads all database and user objects for the connected database. Option selected by default. Only Databases (but include DBC user) Loads all databases and the DBC user, but no other user objects. Only Databases (but include DBC user and myself) Loads all databases, the DBC user, and the current user. Databases and Users with PermSpace Loads all databases and users with PermSpace configured. User Choice (includes DBC) Enables user to select only folders they want displayed in the Data Source Explorer tree hierarchy. If all boxes are checked in What to Display (default), this option is not available. What to Display Use the check boxes in this section to set preferences for which folders you want shown in the Data Source Explorer hierarchical tree display. 16 Option Description Show Databases and Users in Hierarchical Display Displays database and user objects in an expandable hierarchical view. Option selected by default. Include Database Indexes Folder Displays index objects in the Indexes folder. Option selected by default. Include Macros Folder Displays macro objects in the Macros folder. Option selected by default. Include Stored Procedures Folder Displays stored procedures objects in the Stored Procedures folder. Include Tables Folder Displays table objects in the Tables folder. Option selected by default. Include User-Defined Functions Folder Displays user-defined function (UDF) objects in the User-Defined Functions folder. Option selected by default. Include User-Defined Types Folder Displays user-defined type (UDT) objects in the User-Defined Types folder. Option selected by default. Include Views Folder Displays view objects in the Views folder. Option selected by default. Teradata Studio Express User Guide, Release 15.12 Chapter 1: Getting Started With Studio Express Data Source Explorer Load Object Details Select the object details to include when loading objects in the Data Source Explorer. All object details are selected by default. Option Description Load Tables space and journal details If selected, when table information loads in Data Source Explorer, the space and journaling data is included. Option selected by default. Load View Columns Data Types If selected, when view information loads in Data Source Explorer, column data types are included. Option selected by default. Setting Data Source Explorer Load Preferences Use Data Source Explorer Load Preferences to configure your preference settings for loading database and user objects in Data Source Explorer (DSE). You can also set preferences to determine what folders are shown in the hierarchical display. 1. 2. 3. 4. 5. Click Window in the top menu and select Preferences. Expand Teradata Datatools Preferences. Select Data Source Explorer Load Preferences. Under Load options for the Data Source Explorer What to load, select the objects to load: Option Description All Databases and Users Loads all database and user objects for the connected database. Option selected by default. Only Databases (but include DBC user) Loads all databases and the DBC user, but no other user objects. Only Databases (but include DBC user and myself) Loads all databases, the DBC user, and the current user. Databases and Users with PermSpace Loads all databases and users with PermSpace configured. Under What to display, select the folders to show: Option Description Show Databases and Users in Hierarchical Display Displays database and user objects in an expandable hierarchical view. Option selected by default. Include Database Indexes Folder Displays index objects in the Indexes folder. Option selected by default. Include Macros Folder Displays macro objects in the Macros folder. Option selected by default. Include Stored Procedures Folder Displays stored procedures objects in the Stored Procedures folder. 6. Include Tables Folder Displays table objects in the Tables folder. Option selected by default. Include User-Defined Functions Folder Displays user-defined function (UDF) objects in the User-Defined Functions folder. Option selected by default. Include User-Defined Types Folder Displays user-defined type (UDT) objects in the User-Defined Types folder. Option selected by default. Include Views Folder Displays view objects in the Views folder. Option selected by default. [Optional] To select all options to display, click Select All. Teradata Studio Express User Guide, Release 15.12 17 Chapter 1: Getting Started With Studio Express Data Source Explorer 7. 8. [Optional] To clear your selections, click Clear All. In Load Object Details, select one or both of the following options: Option Description Load Tables space and journal details If selected, when table information loads in Data Source Explorer, the load operation includes the space and journaling data. This option is selected by default. Load View Columns Data Types If selected, when view information loads in Data Source Explorer, the load operation includes the column data types. This option is selected by default. 9. [Optional] To reset and restore default selections, click Restore Defaults. 10. To apply your changes, click Apply. 11. Click OK to apply your changes and close the preference dialog. The database and user folders in the Data Source Explorer refresh to reflect the settings you selected. Setting Root of Data Source Explorer Display This feature is available for Teradata Databases displayed in the Data Source Explorer. In the Data Source Explorer Load Preferences, be sure you select the Show Databases and Users in Hierarchical Display check box to display databases. 1. Right-click the Databases folder. 2. Select Teradata > Set Root Database for DSE. The Set Root Database for DSEdialog appears. 3. In Root, type the name of the root database to load and display in the Data Source Explorer hierarchical tree display. 4. Click OK. The database root displays in parenthesis in the Databases folder name. Note: The SYSUDTLIB database always shows in the list of databases. 18 Teradata Studio Express User Guide, Release 15.12 CHAPTER 2 Database Connectivity About Connection Profiles A connection profile contains the connection property information needed to connect to a data source in your enterprise. You can create the following types of connection profiles. Those marked default are the default options in the system. Option Description Aster Database Connects to Teradata Aster Database using the Aster Embedded JDBC Driver (default). DB2 for Linux, UNIX, and Windows Connects to IBM DB2 database for Linux, UNIX, or Windows, also known as DB2 LUW. DB2 for i5/OS Connects to IBM DB2 embedded in the i5/OS operating system for IBM System i (iSeries) formerly AS/400. DB2 for z/OS Connects to IBM DB2 for z/OS for IBM mainframe systems. Generic JDBC Connects using a JDBC database connection. Hadoop Cloudera Connects to Hadoop Cloudera systems using these user-defined options (defaults): • • • • • Teradata Connection to Hadoop (TDCH) for Teradata data transfer SQL-H for Hadoop to Aster data transfer Smart Loader for external file import and export in Hadoop Hive Impala JDBC for creating and running SQL Presto JDBC for creating and running SQL Hadoop Generic System Connects to open source Hadoop systems using the WebHDFS service (default). Hadoop Hortonworks Connects to Hortonworks Hadoop systems using these userdefined options (defaults): • • • • • • Knox Gateway Teradata Connection to Hadoop (TDCH) for Teradata data transfer SQL-H for Hadoop to Aster data transfer Smart Loader for external file import and export in Hadoop Hive JDBC for creating and running SQL Presto JDBC for creating and running SQL Oracle Connects to an Oracle database. SQL Server Connects to a Microsoft SQL Server. Table continued on next page. Teradata Studio Express User Guide, Release 15.12 19 Chapter 2: Database Connectivity Maximum Connections per Profile Preference Option Description Teradata Database Connects to Teradata Databases using the Teradata Embedded JDBC Driver (default). Maximum Connections per Profile Preference This option sets the maximum number of connections allowed per connection profile. This preference applies to Teradata, Aster, and Hadoop (JDBC-enabled) connection profiles. When you are using the maximum number of connections and you try a new SQL operation, a pop-up window reports that you've reached the maximum number of allowable connections. Teradata Database Connectivity Creating a Teradata Connection Profile The Connection Profile contains the JDBC information required to connect to an instance of a Teradata Database. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 20 In the Data Source Explorer or Navigator, click to create a new connection. Select Teradata from Connection Profile Types. At Name, type a name to identify the connection profile. [Optional] At Description, type a description of the connection profile. Click Next. Select a driver from Select a driver from the drop-down. The Teradata Embedded JDBC Driver template is selected as the default JDBC driver template. If you need to create a new Teradata JDBC driver template, click . At Database Server Name, type the host name running the Teradata Database. At User Name[Domain], type the user name for the connection. If you are connecting through Kerberos authentication, include the Domain name. At Password, type the password for the connection. If you are using advanced authentication, such as LDAP or Kerberos, select the Authentication Mechanism. If you did not choose LDAP or Kerberos, the default protected logon is used. [Optional] Set the Database if your connection requires that a default database be set at logon. Select Save Password to save the password. The password is valid for the workbench session. In JDBC Connection Properties, accept the default properties or add and remove JDBC connection properties to specify the connection details for the profile. Teradata Studio Express User Guide, Release 15.12 Chapter 2: Database Connectivity Teradata Database Connectivity The default JDBC connection properties include a QueryBand string that contains query band name value pairs (separated by semicolons) for a session. 14. [Optional] Click Cache Properties to open the Database Cache Properties dialog and select the databases to cache. 15. [Optional] Click Delete Cache Files and confirm to delete cache files. 16. Specify when to connect : Option Description Connect when the wizard completes Connect to the database when you complete the profile. Connect every time the workbench is started Connect to this database each time you launch the workbench. 17. Click Next to view the Summary information. 18. Click Finish to create the connection profile. Kerberos Authentication When using Kerberos authentication, you must provide the TeraJDBC.config security configuration file and specify its location in a Java property. The format of the TeraJDBC.config file is specified in the Teradata JDBC Users Guide. Specify the location of this file in the java.security.auth.login.configure property variable. To add this property variable to the .ini file enter: -Djava.security.auth.login.config=c:/TeraJDBC.config where c:/TeraJDBC.config is the location of the TeraJDBC configuration file. The .ini file (TeradataStudioExpress.ini, TeradataStudio.ini, or eclipse.ini) is located in the same directory as the executable. You must run knint to initialize your Kerberos credential before launching the product. Adding a New Teradata Driver Definition 1. 2. 3. 4. Open the New Connection Profile wizard. Select Teradata from the list of Connection Profile Types and enter a Name for the connection profile. [Optional] Type a Description. Click Next. 5. To add a new driver definition, click . a) Select the Teradata External JDBC Driver template. b) In Driver name, type a unique name for the driver definition. c) On the JAR List tab, add the list of Teradata JDBC Driver JARs. To locate your Teradata JDBC Driver JAR files on the file system, click Add Jar/Zip. d) On the Properties tab, edit the JDBC driver properties. e) Click OK to save your new Teradata Driver definition and return to the New Teradata Connection Profile wizard. Teradata Studio Express User Guide, Release 15.12 21 Chapter 2: Database Connectivity Teradata Database Connectivity Adding a JDBC Property The Add JDBC Properties dialog displays when you add JDBC connection properties in the New Teradata Connection Profile or Teradata JDBC Connection Properties dialog. JDBC connection properties are defined by property value pairs. 1. In JDBC Properties on the Add JDBC Property dialog box, select a JDBC property from the drop-down list. You can also select QUERY_BAND as a property to specify the query bands for a session. 2. Select the value for the property in Select Property Value. 3. [Optional] if the property you select requires a user-defined value, enter the value in the Enter JDBC Property Value dialog. a) In the JDBC Property Value field, type a value for the property. b) Click OK. Also the Enter JDBC Property Value dialog displays if you click Click to enter value in the Select Property Value field. 4. [Optional] To manually enter a JDBC property that is not in the properties list, select the property called USER_ENTERED_PROPERTY and create a new property name value pair. a) In the New JDBC Property dialog, in Property Name, enter the name for the new JDBC property. b) In Property Value, enter the value for the new JDBC property. c) Click OK. 5. Click OK. The JDBC property value pair is added to the JDBC Connection Properties. Editing JDBC Connection Properties You can add or remove connection properties to the list of JDBC Connection Properties. 1. 2. Click Add to display a dialog with the list of JDBC properties. Select the property you want to add. To remove a property, select it and click Remove. To clear the entire list of connection properties click Clear All. 3. From the list of Property Values, select the property value. If the value requires user input, a dialog appears. Default connection properties are supplied for new connection profiles. To override these defaults, click Save Properties. Future definitions use the saved properties. 4. Type in a Property Value of no more than 30 characters. 5. Click OK to save the JDBC property. If the property already exists in the list, a confirmation dialog appears. 6. Click OK to replace the JDBC property in the list. 7. Click Reset to Defaults to set the properties to the default values. 8. To cache schema, use metadataCache Properties. You must enter a user name and password in order to configure the cache properties. To delete all schema cache files for the connection profile, select Delete Cache Files 9. Repeat these steps to add multiple properties. 10. To test the connection, click Test Connection. 22 Teradata Studio Express User Guide, Release 15.12 Chapter 2: Database Connectivity Teradata Database Connectivity A message box appears stating the ping either succeeded or failed. Click OK to close the message box. 11. Select Connect every time the workbench is started to automatically connect to the database when the application is started. 12. Click Finish to close the wizard and connect to your database. Database Cache The Database Cache option enables you to designate specific databases or users to be cached. A database cache file is created to store the metadata for the database. The metadata describes information about the database, such as its tables, columns, constraints, indexes, macros, parameters, stored procedures, userdefined functions, user-defined types, views, and more. This metadata is used to populate the Data Source Explorer and Transfer View trees. Note: The Database Cache option is associated with the Connection Profile. If the Connection Profile is deleted, the Database Cache list and any database cache files that were created are also deleted. Database Cache Inheritance If the Data Source Explorer load option is set to show databases in hierarchical format, child databases and user objects are nested under the parent database or user object. When you select a database or user object to be cached, all of its child database and user objects are also cached. When you change the Data Source Explorer load option, the database cache is deleted and then re-cached using the new selections. Progress Monitor When you first connect to the database and open the Databases folder, the database cache file is created in a background job. To view the progress of the database cache job, open the Progress Monitor view by selecting Window > Show View > Other > General > Progress and clicking OK. About Refreshing Cache After the cache is created, you can click Refresh to refresh the list of databases. Refreshing causes the cached databases to load from the database cache file. You can distinguish the cached databases within the Data Source Explorer tree by looking for the cache icon . If new database objects are modified in the database while it is loaded from the database cache, the modified objects do not display in the Data Source Explorer until you refresh the database cache. To refresh the database cache for a specific database, right-click the cached database and select Refresh Database Cache. This action deletes the database cache file, launches a new background job to create a new database cache file, and refreshes the list of databases. You can also refresh the database cache by deleting the database cache files in the Teradata JDBC Connection Properties dialog. Click Delete Cache Files to delete the database cache files. The Data Source Explorer shows any changes to the database objects. A subsequent refresh of the Databases folder loads the database from the database cache file. Termination of Cache Job Terminating the database cache job causes the database cache files to be deleted and databases to be loaded from the database metadata. To restart the database cache job, you must disconnect and reconnect the Connection Profile, and then click the Databases folder to open it and create the database cache files. Teradata Studio Express User Guide, Release 15.12 23 Chapter 2: Database Connectivity Aster Database Connectivity QueryBand Preferences User QueryBand Settings Options Descriptions Use User QueryBand Select this check box to enable the use of query bands for SQL Editor sessions. Use this option to turn query bands on and off for SQL sessions. User QueryBand Type the query band name value pairs you want available for a session. Separate each query band name value pair with a semicolon (;) and enclose the statement in single quotes ('). For example, 'ApplicationName=CDID;ClientUser=CS99934;'. The field provides a sample query band string with variables you can complete. Fast Load/Export QueryBand Settings Options Descriptions Use Fast Load/Export QueryBand Settings Select this check box to enable the use of query bands on fast load/export query operations. Fast Load QueryBand Type the query band name value pairs you want applied to the fast load/export session. Separate each query band name value pair with a semicolon (;) and enclose the statement in single quotes ('). For example, 'ApplicationName=CDID;ClientUser=CS99934;'. The field provides a sample query band string with variables you can complete. Metadata QueryBand Settings Options Descriptions Use Metadata QueryBand Select this check box to enable the use of query bands when gathering metadata for the Data Source Explorer or Navigator tree. Metadata QueryBand This read-only field shows the metadata query band string used for the session when the Use Metadata QueryBand check box is selected. Aster Database Connectivity An Aster Database connection profile defines the JDBC information required to connect to an instance of an Aster Database on your system. It contains information such as the database server name, user name and password required to establish the connection, port number, JDBC connection properties, and schema cache properties. Creating an Aster Database Connection Profile 1. 2. 3. 4. 24 In the Data Source Explorer or Navigator, click to create a new connection. From Connection Profile Types, select Aster . To filter the list of databases shown in Connection Profile Types, type a filter key (for example Aster) to reduce the list to a subset of database types that match your filter criteria. At Name, type a name to identify the connection profile. [Optional] At Description, type a description of this Connection Profile. Teradata Studio Express User Guide, Release 15.12 Chapter 2: Database Connectivity Aster Database Connectivity 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. Click Next. Select a driver from Select a driver from the drop-down. The Aster Embedded JDBC Driver template is selected as the default JDBC driver template. If you need to create a new Aster JDBC driver template, click . [Optional] Check Set Up SSO Connection to create a connection to an SSO-enabled Aster database server. At Database Server Name, type the host name running the Aster Database. At User Name, type the user name for the connection. At Password, type the password for the connection. Accept the default Port Number or type a different port number. In Database Name, type the name of the database to which this profile connects. Your connection requires that a default database be set when a user logs on. The default database for Aster Database is beehive. Select Save Password to save the password. The password is valid for the workbench session. If you selected Set Up SSO Connection: a) Type the KDC required to connect to the database server. b) Type the Domain Name required to connect to the database server. c) Type the Service Name required to connect to the database server. d) Click Browse and add the location of the JAAS Login Configuration file. In JDBC Connection Properties, accept the default properties or add and remove JDBC connection properties to specify the connection details for the profile. [Optional] Click Cache Properties to open the Schema Cache Properties dialog and select the schemas to cache. [Optional] Click Delete Cache Files and confirm to delete cache files. Specify when to connect : Option Description Connect when the wizard completes Connect to the database when you complete the profile. Connect every time the workbench is started Connect to this database each time you launch the workbench. 19. Click Next to view the Summary information. 20. Click Finish to create the connection profile. Specify a Driver and Connection Details The Specify a Driver and Connection Details dialog enables you to specify the JDBC information required to connect to an instance of an Aster database. The dialog shows the connection properties that define the Connection Profile. Properties include: • • • • Database server name, port, and name of database to which to connect User name and password required to access the Aster database defined in the profile JDBC connection properties Options for caching database files and deleting cache files Teradata Studio Express User Guide, Release 15.12 25 Chapter 2: Database Connectivity Aster Database Connectivity • Options for opening the connection to the database Connection Properties Option Description Select a driver from the drop-down The Aster Embedded JDBC Driver Default template is selected as the default JDBC driver template. If you wish to create a new Aster JDBC driver template, click the asterisk button ( ) to add a driver definition. Database Server Name Name of the database server that hosts the Aster Database. User Name Aster database user name used to connect to the database server. Password Password required to access the Aster database defined in this Connection Profile. Port Number Port number to use for the Aster database server. Database Name Name of the default database. Your connection requires that a default database be set when a user logs on. Save Password Select the Save Password check box if you want the password saved. If this option is not selected, you are required to enter a password each time a connection to the database is made. The password you entered in the Password field is valid for each workbench session and is not affected by this check box. JDBC Connection Properties The JDBC Connection Profile list is blank until you add a property. Use the buttons on the right-side to add, remove, clear, save, and reset properties in the list. Property Actions You can perform these actions for the JDBC connection properties you define. 26 Button Description Add Add JDBC connection properties to the list of JDBC Connection Properties: Remove Remove properties from the list of JDBC Connection Properties by selecting the property and clicking Remove. The property is immediately removed from the list. Clear All Click to clear the entire list of connection properties. Save Properties Click to save the properties listed in the JDBC Connection Properties list. The Save Properties feature overrides the default connection properties supplied for a new connection profile, and saves the list you created. Reset to Defaults Click to set properties to the default values. If you have saved your properties, and therefore, overridden the system defaults, the Save Properties values are used as your default values. Cache Properties Click to configure schema cache properties. This action opens the Schema Cache Properties dialog. See Caching Aster Schemas. Delete Cache Files Click to delete cached files. See Deleting Aster Cache Files. Teradata Studio Express User Guide, Release 15.12 Chapter 2: Database Connectivity Aster Database Connectivity Connection Actions You can verify that the information defined in the Connection Profile connects to the desired Aster database. Option Description Test Connection Click to test the connection. A message box appears stating the ping either succeeded or failed. Click OK to close the message. Connect when the wizard completes Select the check box if you want to connect to the database when you click Finish. Connect every time the workbench is Select the check box if you want to automatically connect to the database started when the application is started. Aster Database Connection Properties The Aster Database Connection Properties dialog details the JDBC information required to connect to an instance of an Aster database. The dialog shows the connection properties that make up the Connection Profile definition. Properties include: • • • • • Database server name, port, and name of database to which to connect User name and password required to access the Aster database defined in the profile JDBC connection properties Options for caching database files and deleting cache files Option to create an SSO (Single Sign On) connection and KDC (Key Distribution Center), domain name, service name, and location of the JAAS (Java Authentication and Authorization Service) configuration file required to access an SSO-enabled system. Connection Properties Option Description Select a driver from the drop-down The Aster Embedded JDBC Driver template is selected as the default JDBC driver template. Set Up SSO Connection Enables an SSO connection, which is disabled by default. Checking this option disables the User Name and Password fields. Database Server Name Name of the database server that hosts the Aster Database. User Name Aster database user name used to connect to the database server. Password Password required to access the Aster database defined in this Connection Profile. Port Number Port number to use for the Aster database server. Database Name Name of the default database. Your connection requires that a default database be set when a user logs on. Save Password Saves a password. If this option is not selected, you are required to enter a password each time a connection to the database is made. The password you entered in the Table continued on next page. Teradata Studio Express User Guide, Release 15.12 27 Chapter 2: Database Connectivity Aster Database Connectivity Option Description Password field is valid for each workbench session and is not affected by this check box. KDC Key Distribution Center required to access an SSO-enabled Aster database server. KDC is disabled by default and is enabled when Set Up SSO Connection is checked. Domain Name Domain name required to access an SSO-enabled Aster database server. Domain name is disabled by default and is enabled when Set Up SSO Connection is checked. Service Name Service name required to access an SSO-enabled Aster database server. Service name is disabled by default and is enabled when Set Up SSO Connection is checked. JAAS Login Configuration The location of the JAAS Login Configuration file required to access an SSOenabled Aster database server. JAAS Login Configuration is disabled by default and is enabled when Set Up SSO Connection is checked. Note: If you are connected to the Connection Profile and change the connection properties, when you click OK, you are asked if you want to reconnect to the server. JDBC Connection Properties The JDBC Connection Profile list is blank until you add a property. Use the buttons on the right-side to add, remove, clear, save, and reset properties in the list. Property Actions You can perform these actions for the JDBC connection properties you define. Button Description Add Adds a JDBC connection properties to the list of JDBC Connection Properties. Remove Removes properties from the list of JDBC Connection Properties. Clear All Clears the entire list of connection properties. Save Properties Saves the properties listed in the JDBC Connection Properties list. The Save Properties feature overrides the default connection properties supplied for a new connection profile and saves the list you created. Reset to Defaults Sets properties to the default values. If you have saved your properties and overridden the system defaults, the Save Properties values are used as your default values. Cache Properties Configures schema cache properties. Delete Cache Files Deletes cached files. Connection Actions You can verify that the information defined in the Connection Profile connects to the desired Aster database. 28 Teradata Studio Express User Guide, Release 15.12 Chapter 2: Database Connectivity Aster Database Connectivity Option Description Test Connection Tests the connection. Connecting to an Aster Database Connection profiles contain all the information required to securely connect to an Aster Database server. 1. Open Data Source Explorer. 2. Right-click an Aster Database connection profile name. 3. Select Connect. The Aster Database Connection Properties dialog opens. 4. Verify the User Name. 5. Type the Aster Database user Password. 6. Click OK. If the connection to the Aster Database is successful, the Data Source Explorer displays the list of databases. If the connection is not successful, an error "Problem Occurred" message displays. Click Details >> to view the error log or click OK to close the message. Disconnecting From Aster Database You disconnect from an Aster Database server by using the connection profile options. 1. In Data Source Explorer, right-click the Aster Database connection profile of the Aster Database server from which to disconnect. 2. Select Disconnect. The Data Source Explorer pane refreshes, and the database list collapses to now display only the name of the Aster Database connection profile. Deleting an Aster Connection Profile You delete a connection profile directly from the Data Source Explorer. 1. 2. 3. 4. Open Data Source Explorer. Right-click the name of the connection profile you want to delete. Select Delete. Click Yes to confirm you want to delete the profile. The Data Source Explorer refreshes and the connection profile name no longer displays in the folder hierarchy. Adding and Editing JDBC Connection Properties You can add JDBC connection properties when you create or edit a connection profile. You also can edit JDBC properties at any time from Data Source Explorer or Navigator. The Add button is located on the right side of the JDBC Connection Properties display area. 1. In Aster Database Connection Properties, click Add. Teradata Studio Express User Guide, Release 15.12 29 Chapter 2: Database Connectivity Aster Database Connectivity 2. 3. 4. 5. The Add JDBC Property dialog displays a list of JDBC properties and values that you can add to the connection profile. Under JDBC Properties, select the property you want to add. [Optional] To enter a JDBC property that is not listed, select USER_ENTERED_PROPERTY, and enter the name and paired value. The property value displays in the Select Property Value field as <name_property>=<property_value>. Click OK. The new property value displays in JDBC Connection Properties. Click Save Properties to save the JDBC property. Note: If the property already exists in the list, a confirmation dialog displays. Click OK to replace the JDBC property in the list. 6. Repeat the above steps to add multiple properties. Changing the Aster User Password You can change the user password set in the Connection Profile for a connection to an Aster Database. 1. 2. 3. 4. 5. In Data Source Explorer, right-click an Aster Database name and select Aster > Change Password. Type the current password. Type the new password. Retype the new password in the Confirm Password field. Click OK. Adding an Aster Database Driver Definition When you create the Connection Profile for an Aster Database, you also can create a new driver definition for that database. 1. 2. 3. 4. Open the New Connection Profile wizard. Select Aster from the list of Connection Profile Types and enter a Name for the connection profile. [Optional] Type a Description. Click Next. 5. To add a new driver definition, click . a) Select the Aster External JDBC Driver template. b) In Driver name, type a unique name for the driver definition. c) On the JAR List tab, add the list of Aster JDBC Driver JARs. To locate your Aster JDBC Driver JAR files on the file system, click Add Jar/Zip. d) On the Properties tab, edit the JDBC driver properties. e) Click OK to save your new Aster Driver definition and return to the New Aster Connection Profile wizard. 30 Teradata Studio Express User Guide, Release 15.12 Chapter 2: Database Connectivity Aster Database Connectivity New JDBC Property Enter a valid JDBC property name and property value for the JDBC property/value pair. Property names and values must not contain commas or equal signs. New JDBC Property Name and Value Option Description Property Name Type the name of the property you want to add to the JDBC Connection Properties list. The name must not exceed 30 characters. Property Value Type the value for the property name. The value must not exceed 30 characters. When you click OK, the property name and value you define display in the Select Property Value field in the Add JDBC Property dialog in the format property_name = property_value. Add a JDBC Property You can add JDBC connection properties when you create a new Connection Profile. You can edit those properties at any time by right-clicking the Connection Profile and selecting Properties. To add a JDBC property, select the JDBC property you want to add and then select the property value. To manually enter a JDBC property, select the JDBC property named USER_ENTERED_PROPERTY. In the New JDBC Property dialog, enter a user-defined property name and value, and click OK. JDBC Properties Option Description Select JDBC Property Select a property from the list. If you select USDER_ENTERED_PROPERTY, the New JDBC Property dialog displays in which you can type a new userdefined property name and value. When you click OK, the property name and value you define displays in the Select Property Value field in the format property_name = property_value. Select Property Value Select a JDBC property value from the list. Names must not exceed the 30 character limit. If no values are displayed in the list, you can select USER_ENTERED_PROPERTY in the Select JDBC Property field and create a user-defined name/value property pair in the New JDBC Property dialog. About Caching Aster Schemas When working with Aster databases, you can designate specific schemas to be cached. Caching Aster schemas creates a schema cache file that contains the metadata for the schema. The metadata describe the schema tables, columns, constraints, indexes, mr functions, views, and so forth. Cached schema are associated with a Connection Profile. If you delete the Connection Profile, the Schema Cache list and any schema cache files associated with that Connection Profile are also deleted. You can cache Aster schema and set cache properties when you: • Create a new Connection Profile - Select cache schemas when you create a new Connection Profile using the New Aster Connection Profile wizard. See Caching Aster Schemas. Teradata Studio Express User Guide, Release 15.12 31 Chapter 2: Database Connectivity Aster Database Connectivity • Edit existing cache schema list - Modify Aster cache properties from the Data Source Explorer. See Editing Aster Cache Schema Properties. Each cached Aster schema node in the Data Source Explorer is indicated by an icon. When you connect to the Aster database and open the Schemas folder, a schema cache file is created in a background job. You can view the progress of the schema cache job in the Progress Monitor view by selecting Window > Show View > Other > General > Progress and click OK. Note: After you select schema to cache or edit cache and open the Schemas folder, the Serialization process occurs. To complete the caching process, you must disconnect and reconnect to the Connection Profile. You can open the Progress Monitor to view the serialization process. Caching Aster Schemas You can cache Aster schema and set cache properties when you create a new Connection Profile using the New Aster Connection Profile wizard. Any schemas that you select in the Schema Cache Properties dialog are cached. You can also modify Aster cache schema properties from the Data Source Explorer. 1. Create a Connection Profile for an Aster Database. 2. In the New Aster Connection Profile wizard select a driver and complete credentials for logging on to the Aster database server. 3. Click Cache Properties on the first page of the wizard. The Schema Cache Properties dialog opens. 4. [Optional] Under Cache Properties select the Cache Selected Schemas check box if you want to view all available schemas for caching. 5. Confirm the connection to the database to get the list of schemas by clicking OK. If the credentials for the Connection Profile are valid and the connection is successful, a list of the schemas associated with the Connection Profile display in the Select Schema area. Note: If the credentials are not valid, an error message displays. 6. From the Select Schema list select one or more schema to cache by checking the box beside the schema name. 7. Click OK. Note: If objects are modified in a cached schema, you must refresh the schema cache to cause the changes to be reflected in the cache. To refresh schema cache, right-click the cached schema object in the Data Source Explorer and select Refresh Schema Cache. Schema Cache Properties The Schema Cache Properties dialog enables you to select Aster schemas that you want cached. Cache Properties Options The following options require a valid set of credentials for connecting to the selected Aster schemas. You provide credentials when you create a Connection Profile, and they are saved in the Connection definition. 32 Teradata Studio Express User Guide, Release 15.12 Chapter 2: Database Connectivity Aster Database Connectivity Option Description Cache Selected Schemas Opens a dialog that confirms you want to proceed with creating a connection to collect a list of schemas. Select Schema Lists the schemas associated with the Connection Profile display in this text area if the credentials for the Connection Profile are valid and the connection is successful. Note: If the credentials are not valid, an error message displays. To test your connection, close the Schema Cache Properties dialog by clicking Close, and click Test Connection. Note: If objects are modified in a cached schema, you must refresh the schema cache to cause the changes to be reflected in the cache. To refresh schema cache, right-click the cached schema object in the Data Source Explorer and select Refresh Schema Cache. Editing Aster Cache Schema Properties You can edit caching properties using the Schema Cache Properties dialog available from the Data Source Explorer. 1. In the Data Source Explorer, right-click the Aster cached schema to be edited. 2. Select Properties. The Schema Cache Properties dialog opens. 3. Select the schemas you want to cache using one of the following options: Option Description Single selection Selects an individual schema. Select all Selects all schema names in the list. Clear all Clears all schema names from the list. 4. Click OK. 5. If you are prompted with a message asking if you want to reconnect to the server, click OK. About Refreshing Schema Cache After you create schema cache files, if you refresh the list of schemas by clicking Refresh, the cached schemas are loaded from the schema cache file. Cached schema are indicated in the Data Source Explorer view with the cache icon . If new database objects are modified in the schema while it is being loaded from the schema cache, the modified objects do not appear in the Data Source Explorer until you refresh the schema cache. To refresh the schema cache, right-click a cached schema and select Refresh Schema Cache. This deletes the schema cache file, launches a new background job to create a new schema cache file, and refreshes the list of schemas. You can also refresh the schema cache by deleting the schema cache files using the Aster Database Connection PropertiesDelete Cache Files option and then reconnecting the Connection Profile. Teradata Studio Express User Guide, Release 15.12 33 Chapter 2: Database Connectivity Hadoop Connectivity The Data Source Explorer now shows the changes to the database objects. A subsequent refresh of the Schemas folder loads the schema from the schema cache file. Deleting Aster Cache Files You can delete Aster cache files using the Delete Cache Files button in these dialogs: • Aster Database Connection Profile wizard • Aster Database Connection Properties Deleting cache files does not disable the caching of Aster schemas. It only deletes the cache files that have been generated. When you connect to the Connection Profile, the files are recreated to cache. Any schemas you selected to be cached in the Cache Schema Properties dialog continue to be cached. To disable caching, you must remove the schema from the Select Schema list in the Cache Schema Properties dialog. 1. Open the Aster Database Connection Profile wizard or the Aster Database Connection Properties dialog. 2. Under JDBC Connection Properties, click Delete Cache Files. 3. When you are asked if you want to delete the cache files, click Yes. Hadoop Connectivity A Hadoop connection profile defines the information required to connect to an instance of a Hadoop Database on your system. It contains information such as the database server name, user name and password required to establish the connection, port number, Hadoop vendor, and connection properties. Creating a Hadoop Generic System Connection Profile 1. 2. 3. 4. 5. 6. 7. In the Data Source Explorer or Navigator, click to create a new connection. Select Hadoop from Connection Profile Types. At Name, type a name to identify the connection profile. [Optional] At Description, type a description of this Connection Profile. Click Next. Select Generic and TDCH as the Connection Service. Specify when to connect: Option Description Connect when the wizard completes Connect to the database when you complete the profile. Connect every time the workbench is started Connect to this database each time you launch the workbench. 8. 9. Click Next. At WebHDFS Host Name, type the host name or IP address of the system configured to provide access to the Hadoop system. 10. At WebHDFS Port Number, type the port number to use to communicate with the WebHDFS service. 11. At System Username, type the user name with permissions to access the WebHDFS host. 34 Teradata Studio Express User Guide, Release 15.12 Chapter 2: Database Connectivity Hadoop Connectivity 12. If the Hadoop cluster has High Availability enabled for the namenode (the cluster has an active and standby namenode), select HA Enabled Cluster, then type the host name or IP address of the standby or backup namenode or host in Secondary WebHDFS Host Name. 13. Click Next to view the Summary information. 14. Click Finish to create the connection profile. Hadoop Cloudera Connection Profiles When creating Hadoop Cloudera connection profiles, you can select different connection options based on your current system connection setup and your data transfer needs. Connection Option Description TDCH Select this option if you plan to use this connection for data transfers between the Cloudera System and a Teradata Database. Teradata Connector for Hadoop (TDCH) enables you to move data between Teradata Databases and Hadoop systems. Manual metadata update for an Impala instance is required. Please refer to the REFRESH/INVALIDATE METADATA statements in the Cloudera Impala documentation. TDCH is not available for Teradata Studio Express. SQL-H Select this option if you plan to use this connection for data transfers from the Cloudera System to an Aster Database. Manual metadata update for an Impala instance is required. Please refer to the REFRESH/INVALIDATE METADATA statements in the Cloudera Impala documentation. SQL-H is not available for Teradata Studio Express. Smart Loader Select this option if you plan to use this connection to import data from text delimited files into a Hadoop System. Impala Select this option if you plan to use this connection to access the Hadoop Cloudera System using SQL from the SQL Editor. This option uses the Hive Impala JDBC Driver to access your Hadoop System. Presto Select this option if you plan to use this connection to access the Hadoop Cloudera System using SQL from the SQL Editor. This option uses the Presto JDBC Driver to access your Hadoop System. Creating Hadoop Cloudera Connection Profiles You can create a Hadoop Cloudera Connection Profile using the connection options in the New Connection Profile wizard. 1. 2. 3. 4. 5. In the Data Source Explorer or Navigator, click to create a new connection. Select Hadoop from Connection Profile Types. At Name, type a name to identify the Connection Profile. [Optional] At Description, type a description of the Connection Profile. Click Next. Teradata Studio Express User Guide, Release 15.12 35 Chapter 2: Database Connectivity Hadoop Connectivity 6. 7. 8. [Optional] Select TDCH if you plan to use this connection for data transfers between the Hortonworks Hadoop System and a Teradata Database. [Optional] Select SQL-H if you plan to use this connection for data transfers from the Hortonworks Hadoop System to an Aster Database. [Optional] Select Smart Loader if you plan to use this connection to import data from text delimited files into a Hadoop Cloudera System. 9. [Optional] Select Impala if you plan to use Hive Impala JDBC to create and run SQL. 10. [Optional] Select Presto if you plan to use Presto JDBC to create and run SQL. If you select this option, you cannot select the Smart Loader option. 11. [Optional] Specify when to connect: Option Description Connect when the wizard completes Connect to the database when you complete the profile. Connect every time the workbench is started Connect to this database each time you launch the workbench. 12. Click Next. 13. If you selected a TDCH and/or Smart Load connection, enter the WebHDFS connection credentials: a) At WebHDFS Host Name, type the host name or IP address of the system configured to provide access to the Hadoop systems. b) At WebHDFS Port Number, type the port number to use to communicate with the Hadoop system. c) At WebHDFS User Name, type the user name with permissions to access the WebHDFS host. d) If the Hadoop cluster has High Availability enabled for the namenode (the cluster has an active and standby namenode), select HA Enabled Cluster, then type the host name or IP address of the standby or backup Namenode/WebHDFS host at Secondary WebHDFS Host Name. e) Click Next. 14. If you selected a SQL-H and/or an Impala or Presto connection, enter the WebHCat connection credentials: a) At WebHCat Host Name, type the host name or IP address of the Apache HCatalog system that manages the metadata services for your Hadoop system. b) In WebHCat Port Number, type the port number to use to communicate with the WebHCat host. c) In WebHCat User Name, type the user name with permissions to access the WebHCat host. d) Click Next. 15. If you specified Impala or Presto, enter the credentials for the JDBC Driver. a) In JDBC Host, type the host name of the Hadoop System to which to connect. b) In JDBC Port Number, type the port number to use to communicate with the host. c) In JDBC Database, type the name of the Hadoop database. d) In JDBC User Name, type the user name to use to connect to the database. e) In JDBC Password, type the password required to access the database using Hive JDBC. f) Select Save Password to save the password. g) Select HTTP Transport Mode to transfer data using the HTTP secure transfer mode. h) In HTTP Path type the HTTP server path or accept the default. i) Select LDAP Security Enabled to enable LDAP authentication. 16. Click Next to view the Summary information. 17. Click Finish to create the connection profile. 36 Teradata Studio Express User Guide, Release 15.12 Chapter 2: Database Connectivity Hadoop Connectivity Hadoop Hortonworks Connection Profiles When creating Hadoop Hortonworks connection profiles, you can select different connection options based on your current system connection setup and your data transfer needs. Connection Option Description Knox Gateway Select this option if you currently connect to your Hortonworks Hadoop System through a Knox Gateway. The Apache Knox Gateway is a REST API gateway for interacting with Hadoop clusters. TDCH Select this option if you plan to use this connection for data transfers between the Hortonworks Hadoop System and a Teradata Database. Teradata Connector for Hadoop (TDCH) enables you to move data between Teradata Databases and Hadoop systems. TDCH is not available for Teradata Studio Express. SQL-H Select this option if you plan to use this connection for data transfers from the Hortonworks Hadoop System to an Aster Database. SQL-H is not available for Teradata Studio Express. Smart Loader Select this option if you plan to use this connection to import data from text delimited files into a Hadoop System. Hive Select this option if you plan to use this connection to access the Hortonworks Hadoop System using SQL from the SQL Editor. This option uses the Hortonworks Hive JDBC Driver to access your Hadoop System. Presto Select this option if you plan to use this connection to access the Hortonworks Hadoop System using SQL from the SQL Editor. This option uses the Presto JDBC Driver to access your Hadoop System. Creating Hadoop Hortonworks Connection Profiles You can create a Hadoop Hortonworks Connection Profile using the connection options in the New Connection Profile wizard. 1. 2. 3. 4. 5. 6. 7. 8. 9. In the Data Source Explorer or Navigator, click to create a new connection. Select Hadoop from Connection Profile Types. At Name, type a name to identify the Connection Profile. [Optional] At Description, type a description of the Connection Profile. Click Next. [Optional] Select Knox Gateway if you currently connect to your Hortonworks Hadoop System through a Knox Gateway. If you select this option, you cannot select Smart Loader or the Hive or Presto JDBC options. [Optional] Select TDCH if you plan to use this connection for data transfers between the Hortonworks Hadoop System and a Teradata Database. [Optional] Select SQL-H if you plan to use this connection for data transfers from the Hortonworks Hadoop System to an Aster Database. [Optional] Select Smart Loader if you plan to use this connection to import data from text delimited files into a Hortonworks Hadoop System. Teradata Studio Express User Guide, Release 15.12 37 Chapter 2: Database Connectivity Hadoop Connectivity If you select this option, Hive is automatically selected as the Hortonworks Hive JDBC Driver will be used to access the Hortonworks Hadoop System. 10. [Optional] Select Hive if you plan to use Hive JDBC to create and run SQL. 11. [Optional] Select Presto if you plan to use Presto JDBC to create and run SQL. If you select this option, you cannot select the Smart Loader option. 12. [Optional] Specify when to connect: Option Description Connect when the wizard completes Connect to the database when you complete the profile. Connect every time the workbench is started Connect to this database each time you launch the workbench. 13. Click Next. 14. If you selected the Knox Gateway option, specify the properties for the Knox gateway connection: a) At Gateway Host, type the host name. b) At Gateway Port Number, type the port number for the host. c) At Cluster Name, type the cluster name. d) At Gateway User Name, type the user name for the Knox Gateway. e) [Optional] In Gateway Password, type the password for the Knox Gateway. f) Select Save Password to save the password. g) Select SSL Enabled to enable Secure Sockets Layer encryption. h) Click Next. 15. If you selected a TDCH and/or Smart Load connection, enter the WebHDFS connection credentials: a) At WebHDFS Host Name, type the host name or IP address of the system configured to provide access to the Hadoop systems. b) At WebHDFS Port Number, type the port number to use to communicate with the Hadoop system. c) At WebHDFS User Name, type the user name with permissions to access the WebHDFS host. d) If the Hadoop cluster has High Availability enabled for the namenode (the cluster has an active and standby namenode), select HA Enabled Cluster, then type the host name or IP address of the standby or backup Namenode/WebHDFS host at Secondary WebHDFS Host Name. e) Click Next. 16. If you selected a SQL-H and/or Hive or Presto connection, enter the WebHCat connection credentials: a) At WebHCat Host Name, type the host name or IP address of the Apache HCatalog system that manages the metadata services for your Hadoop system. b) In WebHCat Port Number, type the port number to use to communicate with the WebHCat host. c) In WebHCat User Name, type the user name with permissions to access the WebHCat host. d) Click Next. 17. If you specified Hive or Presto, enter the credentials for the JDBC Driver. a) In JDBC Host, type the host name of the Hadoop System to which to connect. b) In JDBC Port Number, type the port number to use to communicate with the host. c) In JDBC Database, type the name of the Hadoop database. d) In JDBC User Name, type the user name to use to connect to the database. e) In JDBC Password, type the password required to access the database using Hive JDBC. f) Select Save Password to save the password. g) Select HTTP Transport Mode to transfer data using the HTTP secure transfer mode. h) In HTTP Path type the HTTP server path or accept the default. 38 Teradata Studio Express User Guide, Release 15.12 Chapter 2: Database Connectivity Oracle, DB2, and SQL Server Connections i) Select LDAP Security Enabled to enable LDAP authentication. j) Select JDBC Logging to generate JDBC log information. 18. Click Next to view the Summary information. 19. Click Finish to create the connection profile. Oracle, DB2, and SQL Server Connections The system also supports connections to Oracle, DB2, and SQL Server Connections. These connections are contributed by the vendors to Eclipse. To use these connections, contact the vendor for the JDBC driver and instructions. Teradata Studio Express User Guide, Release 15.12 39 Chapter 2: Database Connectivity Oracle, DB2, and SQL Server Connections 40 Teradata Studio Express User Guide, Release 15.12 CHAPTER 3 Teradata Data Lab About Data Lab A data lab is a separate dedicated work space, also known as a "sandbox", within the data warehouse where you can explore, analyze new data, and test data value theories. Developers of new analytic queries can combine their personal, ad hoc, or temporary data with production data for agile development. About the Data Lab View The Data Lab View provides access to your tables from a Teradata Data Lab. It is a tree view that displays the hierarchy of Data Lab groups with child Data Labs. In the hierarchy, a Data Lab has tables as children. From the view you can copy, load, and export data into Data Labs. The Data Lab View also allows you to create tables derived from external file data using the Smart Load Wizard. Teradata Studio Express User Guide, Release 15.12 41 Chapter 3: Teradata Data Lab About the Data Lab View Teradata Connection Profile Provides access to a list of Connection Profiles. You must connect to the profile before you can select it in the list. The Teradata Database version displays beside the selected profile name. Data Lab Groups Lab groups allocate space for data labs and can be organized to fit your objectives for the labs, such as by individual, function, department, or region. Groups display as a hierarchy with child data labs in expandable views below parent groups. Tables Accessible from Data Lab Tables display as child data labs of a data lab group. Opening the Data Lab View 1. From the Data Transfer perspective, click the Data Lab icon on the toolbar to open the Data Lab View. 42 Teradata Studio Express User Guide, Release 15.12 Chapter 3: Teradata Data Lab Data Lab Copy Wizard Copying Tables to Data Labs The Data Lab View enables you to access tables as child data labs in a data lab group. Copying a Teradata table to a data lab is as easy as dragging the source table from the Data Source Explorer and dropping it into the Data Lab View. The Data Lab Copy Wizard guides you through the steps of performing a table copy. Note: The Copy Wizard is not provided in Teradata Studio Express. 1. 2. 3. 4. Open the Data Source Explorer and navigate to the table object to copy to the Data Lab View. Drag the table object to the Data Lab View and drop it on the parent data lab group. In Copy Table verify the Source and Destination information is correct. If the table does not exist in the data lab group, select from these options: Option Description Copy Data Copies the source table data to the data lab table. To create a new table that is empty, de-select this option. If the target table exists, select to append or replace the data in the Data Lab. Lock Table Locks the table during the copy operation. Locking tables might cause performance to be slow. 5. If the table already exists in the data lab group, select from these options: Option Description Lock Table Locks the table during the copy operation. Append to Existing Data Appends the source table data to the end of the data in the destination table. Replace Existing Data Replaces all existing data in the data lab table with the source table data. 6. 7. Click Next. In Filter Table specify which table columns to copy and then select a filter type and data value to filter the data in the column. This filter creates the SELECT statement for the COPY operation. 8. Click Next. 9. In SQL Preview Filter Table, review the generated SQL for the COPY operation. 10. Click Finish. 11. Monitor the progress of the COPY operation in the Transfer Progress View. Data Lab Copy Wizard About the Data Lab Copy Wizard The Data Lab View supports drag and drop of table objects from Data Source Explorer. When you drop a table into the Data Lab View, the Data Lab Copy Wizard opens. Note: The Copy Wizard is not provided in Teradata Studio Express. Teradata Studio Express User Guide, Release 15.12 43 Chapter 3: Teradata Data Lab Data Lab Copy Wizard Using the wizard you can specify data filters to determine which columns and data to copy to the Data Lab. You can also lock the table while you are transferring data using the Lock Table option. The Copy Wizard displays the following dialogs: Dialog Name Description Copy Table Displays the database and table name of the data source and destination. Use this screen to verify that the copy information is correct. If you are copying to a new table, you can select the Copy Data option to copy the data when the new destination table is created. Clear this option to create an empty table. If you are copying to an existing table in the Data Lab, you must specify whether you want the data appended to the existing data or to replace all existing data with the source table data. Filter Table Enables you to select which columns in the source table to copy to the Data Lab table. After you select a column, you can refine the copy operation by specifying which data in that column to copy. The default is to transfer all data. SQL Preview Filter Table Displays the generated Data Definition Language (DDL) script that copies the source table to Data Lab. The copy job can be run by clicking Finish. About Copy Table When you drag and drop a table from the Data Source Explorer to the Data Lab View, the Copy Wizard displays the name of the source and destination tables in the Copy Table dialog. 44 Teradata Studio Express User Guide, Release 15.12 Chapter 3: Teradata Data Lab Data Lab Copy Wizard Source Database The source information includes the names of the Connection Profile, Database, and Table from which the data is copied. Destination Database The destination information includes the names of the Connection Profile, Database, and Table to which the Copy Wizard copies the data. Instructions for Copy Job You can specify these options for the Copy job: Option Description Copy Data Creates the destination table and copies the source data to the new table. If you want to create an empty table, do not select this option. Lock Table Locks source and destination tables during the data transfer. Teradata Studio Express User Guide, Release 15.12 45 Chapter 3: Teradata Data Lab Data Lab Copy Wizard About Filter Table The Copy Wizard enables you to review the source table columns and specify which columns and data you want copied to the Data Lab destination table. Column Filter Lists filter types available. You must enter a value that is valid for the column data type. The data type displays beside the column name. Column Select for Copy Allows you to select a check box beside a column name to copy the column to the destination table. All columns are selected by default. Actions on All Columns Allows you to perform actions on all columns at the same time. All columns are selected by default. Use the Clear All and Select All buttons to act on all columns in the table. 46 Teradata Studio Express User Guide, Release 15.12 Chapter 3: Teradata Data Lab Data Lab Copy Wizard About SQL Preview Filter Table The generated Data Definition Language (DDL) script that copies the source object to its destination displays in the Generated SQL text area. Generated DDL Script DDL Script generated from the information you provided in previous screens of the Copy Object Wizard. Run this script to perform the copy operation. Teradata Studio Express User Guide, Release 15.12 47 Chapter 3: Teradata Data Lab Data Lab Copy Wizard 48 Teradata Studio Express User Guide, Release 15.12 CHAPTER 4 Query Development Data Tools for Query Development Teradata provides multiple tools to assist you in developing queries for the Teradata databases in your system. Data Tools Description Teradata SQL Editor Extends the Eclipse Data Tools Platform (DTP) SQL Editor to provide SQL development on Teradata databases. SQL Query Builder Extends the Eclipse Data Tools Platform (DTP) SQL Query Builder to provide execution on Teradata databases. Compare Editor Compares the Data Definition Language (DDL) text of two database objects. Compare SQL Object Wizard Enables you to compare the Data Definition Language (DDL) text in a database object with another object of the same type in either a Teradata Database or Aster Database. Result Set Viewer Provides an enhanced view of a result set that includes options to hide columns, filter on column values, find column values, copy data to the clipboard, format cell data, and switch between grid and text view. SQL History View Provides historical information about SQL/DDL executions on one or more databases in your system. Statistics Collection View Collects the statistics on table columns and indexes that are important to producing query plans. Teradata SQL Editor About the SQL Editor The SQL Editor provides an integrated environment for the development of SQL files that enables you to develop SQL statements for execution. The editor enables you to validate SQL syntax, save files to a project or export to system files, and execute all SQL in a file or execute the SQL as individual statements. You must specify a Connection Profile before you can execute an SQL query statement. The SQL Editor displays when you open an SQL/DDL file or when you select the Query Development Perspective. Double-clicking an SQL/DDL file in the Project Explorer opens that file in the editor. You can also open the SQL Editor by clicking Teradata Studio Express User Guide, Release 15.12 in the Query Development perspective. 49 Chapter 4: Query Development Teradata SQL Editor Connection Profile Name Selects the profile in which to run the SQL script. You do not have to connect to a Connection Profile to display the Connection Profile name in the list. Editor Work Area Displays the active SQL edit window. You can insert, delete, and modify SQL statements displayed in this area. Connection Status Indicator Shows the status of the connection to the selected Connection Profile. Green indicates that the connection is active. Autocommit Toggle When selected, submits each SQL statement in autocommit mode. Each SQL statement is then executed in its own transaction that ends with a COMMIT statement. You cannot roll back an SQL statement that is executed in autocommit mode. When Autocommit is set to ON, the Autocommit check box in the toolbar is selected. To turn Autocommit OFF, clear the check box. Max Rows Changes the maximum number of rows returned by SQL executed in this editor. SQL Execution Options Displays a list of Execute options. You can select to Execute an Individual Statement that you have selected, or to Execute All query statements in the editing pane. SQL Editor Toolbar A set of tools to manage and execute SQL. Content Assist Provides aids for validating, debugging, and editing the SQL queries you develop in the editor. You can use the Text Editors preference settings ( Window > Preferences > General > Editors > Text Editors) to change the appearance of the SQL Editor, including displayed tab widths, color options, line numbers, mouseovers, and more. Using the SQL File Editor The Teradata SQL Editor supports: • Teradata Database connection profiles • Aster Database connection profiles • Hadoop File System connection profiles with JDBC enabled 50 Teradata Studio Express User Guide, Release 15.12 Chapter 4: Query Development Teradata SQL Editor If you are working with SQL files located on a different type of database, such as Oracle or MS SQL Server, you must work in the SQL File Editor. 1. Do one of the following: 2. 3. 4. 5. 6. 7. 8. • In Project Explorer, right-click the SQL folder. • Open the SQL Editor and right-click in the main editor pane. Select Open With > Other.... The Editor Selection dialog displays. Select SQL File Editor. Click OK. Under Connection Profile, select the Type of database for this connection; for example, Oracle_10 or SQL Server_2005. Select the Name of the connection profile from the list. Only existing connection profiles display in the list. Select the Database name from the list. Aster and Hadoop have no database name. Verify the status of the profile you selected. Status information displays to the right of the Database name. If no connection profile exists for a particular profile type, the Name and Database fields are blank. Drag and Drop into SQL Editor You can drag objects from the Data Source Explorer and drop them into the SQL Editor to build your SQL statement. The object name appears in the SQL Editor at the location where you drop it. SQL Editor Preferences The SQL Editor preferences customize the behaviors and look-and-feel of the SQL Editor. To set preferences for general editor appearance and behaviors, go to Window > Preferences > Data Management > SQL Development > SQL Editor. General Tab You can specify the following general preference settings: Syntax Validation Validates the syntax of the SQL statement. Option Description Enable syntax validation Syntax validation automatically updates the structure of an SQL statement in the Outline view and performs the syntax validation as you edit. The SQL Parser parses the SQL statement according to the grammar for the version of Teradata or Aster specified in the Connection Profile. Note: Disabling validation also disables portability checking and the Outline view. Table continued on next page. Teradata Studio Express User Guide, Release 15.12 51 Chapter 4: Query Development Teradata SQL Editor Option Description Portability check target Selects the Teradata database type to use as the standard target for portability checks. You must enable syntax validation to select a portability target. Select None to indicate no database type for portability checks (default). Each line that is not portable to the target is annotated with a check. You can display additional information by placing the cursor over the marker. Maximum number of lines Specifies the maximum number of lines of SQL content to validate before disabling syntax validation. Select a number that optimizes validation without impacting editor performance. The default is 1000. Clear the check box to indicate no restriction to the number of lines of SQL to validate. Prompt to disable system validation when content exceeds maximum number of lines Displays a message asking if you want to disable system validation. The message displays if the number of lines in the SQL file exceeds the value entered in Maximum number of lines. Show detailed annotation information When selected enables the SQL Editor to display the list of possible correct syntax options when a syntax error occurs in the SQL statement. Execute Current Text Specifies what delimits the current text when you select Execute Current Text from the SQL Editor menu. Option Description Execute SQLs between delimiters Selects the delimiter used in text to separate SQL statements for execution. Execute current line Selects only the currently selected line of SQL code is to be executed. Execute SQLs between blank lines Selects to use blank lines as the delimiters for separating SQL statements for execution. Typing Tab Select check boxes to enable or disable typing aids that are available when editing in Smart Insert mode. Click to select an option and display the SQL in the Preview text area. 52 Option Description Close single quotes Inserts characters to close a single quote in the SQL Editor. Close double quotes Inserts characters to close a double quote in the SQL Editor. Close parentheses Inserts characters to close a parentheses in the SQL Editor. Close comments Inserts characters to close multi-line comments in the SQL Editor. For example, if you type /* to indicate the start of a comment, the editor inserts */ to close the comment. Begin-End Adds the End with proper indentation in the SQL Editor, and then moves the cursor to a new line between Begin/End with proper indentation. Teradata Studio Express User Guide, Release 15.12 Chapter 4: Query Development Teradata SQL Editor SQL Formatter Preferences This preference page is where you can configure the options which control the Teradata formatting strategy for SQL text using the following options: Main Option Description Keyword Case Option Specifies how to format keywords using the following sub-options: Identifier Case Option Stacking Lists Option Uppercase Converts all keywords to uppercase Lowercase Converts all keywords to lowercase Starts with Uppercase Converts only the first letter to uppercase and the rest of the keyword is lowercase Unchanged Keywords are left as they were Specifies how to format identifiers using the following sub-options: Uppercase Converts all identifiers to uppercase Lowercase Converts all identifiers to lowercase Starts with Uppercase Converts only the first letter to uppercase and the rest of the identifier is lowercase Unchanged Identifiers are left as they were Specifies how to arrange lists, such as Select lists, From lists, Order By lists, Group By lists, Parameter lists, and Column definition lists. If there is only a single item in the list, the formatter always places it on the same line as the context keyword, regardless of the option. Same Line Places list items all on the same line Line Break After Comma Places a line break after the comma Line Break Before Comma Places a line break before the comma Line Break Before Comma with Space Places a line break before the comma and adds a space after the comma Unchanged Lists are left as they were Indentation Option Specifies whether to use spaces or tabs for indentation. Space Size Specifies the size of the indentation for spaces. The value must be between 0 and 9. If tabs were chosen for the indentation option, the tab size is specified on the General > Editors > Text Editors Preference page (Displayed tab width). Where Clause Break Option Specifies whether to place the AND and OR elements of the WHERE clause on separate lines or the same line. Teradata Studio Express User Guide, Release 15.12 Line Break and Indent Places the list of AND and OR elements on new lines at the indentation level. Same Line Places the list of AND and OR elements on the same line. 53 Chapter 4: Query Development Teradata SQL Editor SQL Editor Toolbar The SQL Editor toolbar enables Connection Profile selection and action buttons that help you manage and execute SQL for supported databases. The SQL Editor Toolbar contains the following: Connection Profile Select a Connection Profile from the list. If the selected profile is not connected, confirm you want to connect by clicking Yes, enter the connection password, and click OK. Connection Status Shows the status of the connection to the selected Connection Profile. Green indicates that the connection is active. Autocommit Toggle When selected, submits each SQL statement in autocommit mode. Each SQL statement is then executed in its own transaction that ends with a COMMIT statement. You cannot roll back an SQL statement that is executed in autocommit mode. When Autocommit is set to ON, the Autocommit check box in the toolbar is selected. To turn Autocommit OFF, clear the check box. Connect to Selected Profile Connects to the connection profile, if it is disconnected. Commit If Autocommit is off, performs a commit. Rollback If Autocommit is off, performs a rollback. Max Rows Changes the maximum number of rows returned by SQL executed in this editor. SQL Execution Options Displays a list of Execute options. You can select to Execute an Individual Statement that you have selected, or to Execute All query statements in the editing pane. Cancel Running Statements Aborts a running SQL request. Save Options Saves the SQL file to a project. Export Results to File When toggled on, exports the SQL results to a file instead of displaying in the Result Set viewer. Import Data to Volatile Table Lets you load external data into a volatile table. Clear Query Clears the SQL displayed in the editor. Rename Editor 54 Teradata Studio Express User Guide, Release 15.12 Chapter 4: Query Development Teradata SQL Editor Renames the editor. View Result Sets View result sets created by this editor. New SQL Editor Opens a new SQL Editor. This action does not close the current editor, enabling you to work with multiple editors in tandem. SQL Handling Preferences Opens the SQL Handling Preferences. SQL Handling Common The Results Handler options enable you to select a result set handler to process SQL result sets. Option Description Qualify names for drag and drop in SQL Editor (Default) Clear this check box if you do not want names qualified when you drag and drop objects from the Data Source Explorer to the SQL Editor. Prompt for notes Check this check box if you want to be prompted to enter SQL execution notes. When you execute SQL statements, a dialog appears which prompts you to enter the note. The SQL History view displays your note text in the Note column. Auto-connect to profile when selected in SQL Editor Select this check box to automatically connect to the selected profile within an instance of the SQL Editor. (Default) Results Handler Select one: • • Sampler Content Size Teradata Export Wizard (File Export) — option handles result sets by exporting SQL to a file using the Teradata Export Wizard . (Default) Teradata Result Set Viewer — option displays SQL result sets in the Result Set Viewer. Type a value for the sample content size. Default is 100. Teradata The following Large Value Handling settings enable you to set column size restrictions for creating BLOBs and CLOBs in Teradata tables. Option Description Handle Binary/Byte columns as BLOBs if size > Specify the limits for creating BLOBs for large binary values in results. Binary results are treated as BLOBs when their column size is greater than the value you enter. A value of zero specifies that all binary values are treated as BLOBs. Default is 30. Table continued on next page. Teradata Studio Express User Guide, Release 15.12 55 Chapter 4: Query Development Teradata SQL Editor Option Description Handle Character columns as CLOBs if size > Specify the limits for creating CLOBs for large character values in SQL results. Character values in results are treated as CLOBs when their column size is greater than the value you enter. A value of zero specifies that all character values are treated as CLOBs. Default is 16384. Aster The following Large Value Handling settings enable you to set size restrictions for creating BLOBs and CLOBs in Aster tables Option Description Handle Binary/Byte columns as BLOBs if size > Specify the limits for creating BLOBs for binary results. Binary results are treated as BLOBs when their column size is greater than the value you enter. A value of zero specifies that all binary values are treated as BLOBs. Default is 30. Handle Character columns as CLOBs if size > Specify the limits for creating CLOBs for results. Character values in results are treated as CLOBs when their column size is greater than the value you enter. A value of zero specifies that all character values are treated as CLOBs. Default is 2147483647. Sounds The Sounds settings enable you to customize audible indicators for success and failure notification sounds during SQL execution. Option Description Success Sound Select one of these options: • • • No sound (default) System Beep Secret Sound If you select Secret Sound, click Browse to select a sound file on your system. Failure Sound Select one of these options: • • • • Success Sound No sound (default) System Beep Secret Sound If you select Secret Sound, click Browse to select a sound file on your system. BLOB Disposition The BLOB Disposition form appears in the LOB Disposition Dialog when the results contain columns with large binary values. The form contains the following fields: 56 Teradata Studio Express User Guide, Release 15.12 Chapter 4: Query Development Teradata SQL Editor Field Description Column Name View the name of the column in the results. Save to File Saves the values of the column to files. When this check box is cleared the fields for specifying the name and location of files are unavailable. Display images in Result View Displays the values that can be decoded as images in the result view as images. Location Enter the name of the folder where the files are to be saved. Browse Click to display a dialog box that allows you to browse for the Location. File Base Name This is the main component of the name of the files that are created for the large objects. The final name consists of the base name, the number of the row in the results that contains the value, and the File Extension. File Extension File extension component of the name of the files that are created for the large objects. CLOB Disposition The CLOB Disposition form appears in the LOB Disposition Dialog when the results contain columns with large character values. The form contains the following fields: Field Description Column Name View the name of the column in the results. This field can not be modified. Save to File Saves the values of the column. When this check box is cleared, the fields for specifying the name and location of files are unavailable. Location Type the name of the folder where the files are to be saved. Browse Click to browse for the folder to be the Location value. File Base Name Base name to give to the files created for the large objects. The final name consists of the base name, the number of the row in the results that contains the value and the File Extension. File Extension File extension to give to the files created for the large objects. File Encoding Name of the encoding to use when the character values are written to the files. LOB Disposition The LOB Disposition dialog appears when the results of running an SQL statement contain CHARACTER LARGE OBJECT (CLOB) or BINARY LARGE OBJECT (BLOB) values, or character or binary values specified to be treated as large objects. The dialog contains a form for each column of the results that is a large object type. The forms enable you to specify how to handle the values. You can specify to store the values in files. In the case of binary data, you can specify that the values that are images are displayed in the Result View. The forms for specifying how the values are to be handled are: • CLOB disposition: Specify the handling of large character values • BLOB disposition: Specify the handling of large binary values Teradata Studio Express User Guide, Release 15.12 57 Chapter 4: Query Development Teradata SQL Editor As you enter values in the forms, the message at the top of the dialog indicates if there is an invalid value. When a form contains an invalid value the OK is disabled. Clicking Cancel displays a dialog that indicates large values are not saved to files. Setting SQL Handling Preferences Use the SQL Handling Preferences dialog to set very large value handling rules for objects, such as BLOBs, CLOBs, and LOBs, in the SQL Editor. 1. Click Window in the top menu and select Preferences. 2. In the Preferences navigation pane, expand Teradata Datatools Preferences. 3. Select SQL Handling. The SQL Handling dialog displays in the right pane. There are three tabs: Common, Teradata, and Aster. 4. Click the Common tab to set SQL rules for both Teradata Database and Aster database. a) Select Qualify names for drag and drop in SQL Editor to qualify names when objects are dragged from the Data Source Explorer and dropped in the SQL Editor. Clear this check box if you do not want names qualified. b) Select Prompt for notes to be able to enter a note when you execute SQL. The Note dialog lets you enter a text value that displays in the Teradata SQL History view in the Note column. c) Under Results Handler, the Teradata Result Set Viewer is selected as the results handler for processing SQL result sets. 5. Click the Teradata tab to set large value handling rules in Teradata Databases. a) In Handle Binary/Byte columns as BLOBs if size >, type the number of bytes for column size which when exceeded, the object is handled as a binary large object (BLOB). Note: A value of zero specifies that all binary values are handled as BLOBs. b) In Handle Character columns as CLOBs if size >, type the number of characters which when exceeded, the object is handled as a character large object (CLOB). The default is 2147483647. Note: A value of zero specifies that all character values are handled as CLOBs. 6. Click the Aster tab to set large value handling rules in Aster databases. a) In Handle Binary/Byte columns as BLOBs if size >, type the number of bytes for column size which when exceeded, the object is handled as a binary large object (BLOB). Note: A value of zero specifies that all binary values are handled as BLOBs. b) In Handle Character columns as CLOBs if size >, type the number of characters which when exceeded, the object is handled as a character large object (CLOB). The default is 2147483647. Note: A value of 0 (zero) specifies that all character values are handled as CLOBs. 7. [Optional] To clear selections and restore default settings, click Restore Defaults. 58 Teradata Studio Express User Guide, Release 15.12 Chapter 4: Query Development Teradata SQL Editor 8. To apply your changes, click Apply. 9. Click OK to apply your changes and close the Preferences dialog. Execute SQL The SQL Editor provides various options to execute SQL statements within an SQL file. To access the following options, click the appropriate button in the toolbar or right-click inside the SQL Editor text area. Option Label Description Execute as Individual Statements Executes all statements or selected statements one at a time, displaying the result as a Teradata Group Execution in the SQL Results view. This option allows you to execute SQL DDL statements, which requires its own COMMIT between statements. The group result includes an individual SQL Result for each statement. Execute All Executes all SQL statements in the SQL File and displays the result as a single entry in the SQL Results view. Multiple result sets display in multiple Result tabs. Running SQL Teradata Studio has the following ways to run SQL operations on your Teradata systems: • The SQL Editor provides the ability to define and run SQL statements. See the Using the SQL Editor topic for details of how to run SQL statements from the SQL Editor. • Run Configurations let you define operations that you can run from the Run menu and Run toolbar button. See the Running SQL from Run Menu and Toolbar topic for details of how to specify run configurations and how to run them. • Running database objects - Several types of objects can be "run" in from the Data Source Explorer. See the following section for details. Running Database Objects Another way that operations can be performed in the database is by using the Run menu item in the popup menu shown when you right-click certain objects in the Data Source Explorer tree. The types of objects that can be Run from the Data Source Explorer are (followed by the result of selecting Run): • Stored Procedures - Displays the Configure Parameters dialog box where the procedure's parameters are specified. The Stored Procedure is called with the specified parameters. The values of the parameters after the call is completed, including the OUT and INOUT parameters, are shown in the Parameters tab of the SQL Results view. • User-defined Functions - Displays the Configure Parameters dialog box where the procedure's parameters are specified. The UDF is SELECTED with the specified parameters. The values of the parameters are shown in the Parameters tab of the SQL Results view. The value of the UDF is shown in the Result1 tab. • Macros - Displays the Configure Parameters dialog box where the procedure's parameters are specified. The macro is executed with the specified parameters. The results of the macro are shown in the Result tab(s) of the SQL Results view. Teradata Studio Express User Guide, Release 15.12 59 Chapter 4: Query Development Teradata SQL Editor • Triggers - Displays the Edit Configuration dialog box where the SQL statement that performs the operations that causes the trigger to be run is specified. The specified SQL statement is run and the results of the SQL operation are shown in the SQL Results view. When SQL operations are performed using the Run menu item, a launch configuration specifying the way the operation was run is created. See the Running SQL from Run Menu topic for details of how to rerun, edit and remove the automatically created launch configurations. Format SQL Command The Format SQL toolbar command formats the SQL statement in the SQL Editor. The formatter uses the formatting options specified in the SQL Formatter Preferences. The SQL Formatter Preferences are available from Window > Preferences > Teradata Datatools Preferences in the main menu. Set Connection Information The Set Connection Info menu option changes the Connection Profile for an SQL Editor file. You can select the database server type, connection profile name, and database name from the drop down lists then click OK. SQL Editor Templates SQL templates for creating SQL statements in the SQL Editor are provided in three ways: • Generate SQL options — SELECT, INSERT, UPDATE, and DELETE statement templates for tables. These Generate SQL options are available from the Query Development perspective when you right-click a table object in Data Source Explorer. • Content Assist templates — In-context insertion of SQL statements in SQL Editor. To invoke the SQL Templates, place your cursor at the point in the SQL text where you want assistance and enter CNTL +SPACE. • Templates View for Aster analytical functions — Aster-only view that displays a list of function templates you can drag and drop into the SQL Editor. Templates provided through the Content Assist mechanism help you create Data Manipulation Language (DML) type SQL statements, such as DELETE, INSERT, SELECT, and UPDATE. Template variables support tabbing from one variable to another. Template variables are linked allowing you to change one occurrence of a variable, for example, tablename1, and automatically change all occurrences of that same variable in the template. The Content Assist selection list includes all available SQL templates for creating SQL at the cursor insertion point in the text. Retrieving Table Rows using a SELECT Template 1. Click Query Development to open the Query Development perspective. 2. Open the Data Source Explorer and navigate to the Teradata or Aster database table in which you want to insert rows. 3. Right-click the table object and select one of these options: 60 Teradata Studio Express User Guide, Release 15.12 Chapter 4: Query Development Teradata SQL Editor For Select Teradata Database Teradata > Generate SQL > SELECT Statement Aster Database Aster > Generate SQL > SELECT Statement Hadoop File System Hadoop > SELECT Statement 4. In the SQL Editor, review the generated SELECT statement and edit as needed. 5. Click to execute the SELECT statement to retrieve the row in the table. Inserting Table Rows using an INSERT Template You can generate an INSERT statement template in the SQL Editor that inserts rows in a Teradata or Aster database table. The INSERT (Values) Statement menu option enables you to modify the generated statement and provide all query values. If you want to create a parameterized query, select the INSERT (Parameterized) Statement menu option. 1. Click Query Development to open the Query Development perspective. 2. Open the Data Source Explorer and navigate to the table in which you want to insert rows. 3. Right-click the table object and select one of these options:. For Select Teradata Database Teradata > Generate SQL > INSERT (Values) Statement Aster Database Aster > Generate SQL > INSERT (Values) Statement 4. In the SQL Editor, modify the generated INSERT statement to specify the values for the columns based on data types. 5. Click to execute the INSERT statement to insert the row into the table. Inserting Table Rows using Parameterized Queries You can generate an INSERT statement template in the SQL Editor that uses parameter placeholders in those cases where you could specify constants. When you execute the SQL, the editor prompts you to specify the values for each of the parameter placeholders. You also have the option to load the default values for the parameters. 1. Click Query Development to open the Query Development perspective. 2. Open the Data Source Explorer and navigate to the database table in which you want to insert rows. Teradata Studio Express User Guide, Release 15.12 61 Chapter 4: Query Development Teradata SQL Editor 3. Right-click the table object and select one of these options:. For Select Teradata Database Teradata > Generate SQL > INSERT (Parameterized) Statement Aster Database Aster > Generate SQL > INSERT (Parameterized) Statement 4. In the SQL Editor, review the generated INSERT statement and edit as needed. 5. Click to execute the INSERT statement. 6. In Configure Parameters, specify the values for each of the parameters or click Load Defaults to specify default values. 7. Click OK. The SQL INSERT statement runs and inserts the row in the table. Parameterized Queries SQL statements can contain parameter placeholders (question marks) in most cases where you can specify constants. When you run SQL that contains one or more parameter placeholders from the SQL Editor, you are prompted to specify the values for each of the parameters. The values you specify are substituted for the parameter placeholders when the SQL executes. Named Parameters A special SQL element in the SQL Editor enables you to assign names to parameter placeholders. The form of the new element is: ?\name This form follows the rules of forming unquoted names which is a question mark followed by a back slash followed by a name with no space between the parts. Parameters that are specified without a name, that is, by using just the question mark alone, display with the name "Parameter n" where the n indicates the index of the parameter for the SQL value. For character string or binary columns, the Configure Parameters dialog provides a From File option which reads the input value from a file. To specify the input file, select the cell ellipsis (...) and display a dialog in which you can specify the input file. Reexecuting Parameterized Queries When you select an entry in the list of operations in the SQL Results view that is produced by running parameterized SQL and select Reexecute from the context menu, you are presented with a dialog for specifying the parameter values. The dialog initially contains the values that were used to produce the results. 62 Teradata Studio Express User Guide, Release 15.12 Chapter 4: Query Development Teradata SQL Editor Updating Table Rows using an UPDATE Template You can generate an UPDATE statement template in the SQL Editor to update table rows. 1. Click Query Development to open the Query Development perspective. 2. Open the Data Source Explorer and navigate to the database table in which you want to delete rows. 3. Right-click the table object and select one of these options: For Select Teradata Database Teradata > Generate SQL > UPDATE Statement Aster Database Aster > Generate SQL > UPDATE Statement 4. In the SQL Editor, review the generated UPDATE statement and optionally add conditions to the WHERE clause to update rows. 5. Click to execute the UPDATE statement and update the row in the table. Deleting Table Rows using a DELETE Template You can generate a DELETE statement template in the SQL Editor to delete rows in an Aster Database table. 1. Click Query Development to open the Query Development perspective. 2. Open the Data Source Explorer and navigate to the Teradata or Aster database table in which you want to delete rows. 3. Right-click the table object and select one of these options: . For Select Teradata Database Teradata > Generate SQL > DELETE Statement Aster Database Aster > Generate SQL > DELETE Statement 4. In the SQL Editor, review the generated DELETE statement and optionally add conditions to the WHERE clause to delete rows. Teradata Studio Express User Guide, Release 15.12 63 Chapter 4: Query Development Teradata SQL Editor 5. Click to execute the DELETE statement and delete the row in the table. Inserting Aster Analytical Functions The Aster Database includes scripts for analytical function templates that you can insert into the SQL Editor. 1. Select a connection profile that connects to an Aster Database. 2. Click Query Development and launch the SQL Editor. The SQL Editor, Result Set Viewer, and Teradata SQL History views open. 3. In the main toolbar, select Windows > Show View > Other The Show View dialog opens. 4. Scroll up to General and select TemplatesView which is located at the bottom of the list. The Templates View opens below the SQL Editor. You can drag and dock the view in the left pane beside the Data Source Explorer to see the full list easily. 5. Select a function in the Templates View and preview the script text in the Preview area below the view. 6. Drag and drop the selected Aster function into the SQL Editor to insert it. The text for the Aster analytical function displays at the point you drop it in the SQL Editor script. 7. Substitute your values for the template variables and execute the script. 64 Teradata Studio Express User Guide, Release 15.12 Chapter 4: Query Development About Teradata SQL Query Builder About Teradata SQL Query Builder Teradata SQL Query Builder extends the Eclipse Data Tools Platform SQL Query Builder to provide execution on Teradata. SQL Query Builder provides a graphical interface to create, edit, or run SQL statements. It provides access to your database schema and objects so that you can quickly create or edit SQL statements without actually typing any SQL code. You also have the flexibility to add or modify the SQL code in the editor window. You can open the Teradata SQL Query Builder in the SQL Editor by right-clicking an SQL file in the Project Explorer and choosing the Open With option, then selecting Teradata SQL Query Builder from the list of Editor choices. Note: You must have a Connection Profile assigned for the SQL file. Note: Some syntactic variations might exist between Teradata SQL syntax and the SQL syntax that the Eclipse DTP SQL Query Builder supports; consequently, some SQL Query Builder features might not work with Teradata SQL syntax. For example, Teradata allows for abbreviated keywords such as "sel" for "select", or "ins" for "insert", which the DTP SQL syntax does not support. Note: Also, if multiple SQL statements exist in the file, SQL Query Builder uses the first statement and ignores the rest. It also does not handle nested SELECT statements. The Teradata SQL Query Builder supports four types of SQL statements: SQL Statement Type Description SELECT Creates a SELECT statement to retrieve data from a database and displays the result set in a table format. INSERT Creates an INSERT statement to insert rows into the table. UPDATE Creates an UPDATE statement to update data in a table. DELETE Creates a DELETE statement to remove data from a specified table. The SQL Query Builder provides tabs to edit the Columns, Conditions, Groups and Group Conditions. Right-clicking the graphical area background provides options to add tables or create joins. Right-clicking a table provides options to add a table, create a join, replace a table, select all columns, deselect all columns, update an alias, and remove a table. You can also drag table objects from the Data Source Explorer and drop them in the graphical display of the SQL Query Builder to easily add tables to your SQL statement. The SQL Query Builder can also be launched from the SQL Editor context menu by selecting a SQL statement then choosing the option Edit in SQL Query Builder. The SQL Query Builder displays the SQL statement as well as a graphical view of the tables, columns, and table joins. Note: If you select an existing statement to edit in the SQL Query Builder, make sure that the tables are qualified with the database name or that the designated database from the Connection Profile is the database involved in the SQL statement. Otherwise the SQL Query Builder does not recognize the columns and table joins for the graphical display. Also, if you perform a "SELECT *", the columns are not selected (checked) in the graphical view of the table. Only columns specifically named in the query are selected (checked) in the graphical view of the table. Teradata Studio Express User Guide, Release 15.12 65 Chapter 4: Query Development Result Set Viewer An Outline Viewer is displayed to the right of the graphical display. This shows a high-level outline view of the SQL Statements. Result Set Viewer The Result Set Viewer provides an enhanced view of the result set, including options to hide columns, filter on column values, find column values, copy data to the clipboard, format cell data, and switch between grid and text view. The result set is displayed in its own view with its own toolbar. You can change preferences to customize the view by, for example, displaying alternating row background colors, enabling or disabling row numbers, column headers, table grid lines, and thousand separator on numeric columns. You can change the max display row count, as well as the display null value and date format. Refer to Result Set Viewer Preferences for more detailed information of the Result Set Viewer preferences. The Single Result Set Toolbar contains: Icon Option Description Preferences Click to open the Result Set Viewer Preferences page. Show SQL Click to open a dialog that displays the SQL statement. Set Focus Click to set the focus to the associated SQL editor. Rename Result Tab Click to open a dialog that allows you to rename the result tab. Text or Grid Display Click to switch the view of the result set data between grid or text. The default is grid. Format Selected Cells Click to open the platform specific Font dialog which enables you to select the font, size, and color (on most platforms) of the selected cells. Pin Result Set Click to pin the result set. Pinned result sets are not closed by the Clear All action. Pinned result sets must be closed manually. Clear All Click to clear all result sets in the Viewer. Save Click to save the result set data to a file within the workspace. The Eclipse Save Result dialog appears, which allows you to select the project, file name, file type, and export options. Export Click to export the result set data to an external file. The Eclipse Export Result dialog appears, which allows you to select the file name, format, and export options. Print Click to print the result set data. The Eclipse Print dialog appears, which allows you to select the printer, page range, and number of copies. The Multiple Result Sets Toolbar contains: Icon Option Description Preferences Click to open the Result Set Viewer Preferences page. Show SQL Click to open a dialog that displays the SQL statement. Table continued on next page. 66 Teradata Studio Express User Guide, Release 15.12 Chapter 4: Query Development Result Set Viewer Icon Option Description Rename Result Tab Click to open a dialog that allows you to rename the result tab. Rename Group Result Tab Select one of the group result tabs while in Tab display mode. Right- click the tab and select the Rename Group Result tab menu option. Text or Grid Display Click to switch the view of the result set data between grid or text. The default is grid. Sash or Tab Display Click to switch the display of the multiple result sets between a tab folder or side-by-side sash framework. The default is tab folder. You can remove a result set from the sash framework by clicking the . Note: When result sets are displayed in a sash framework, you can not select a single result set for export, save, or print options. Pin Result Set Click to pin the result set. Pinned result sets are not closed by the Clear All action. Pinned result sets must be closed manually. Refresh Result Set List Click to refresh all of the removed result sets. Save Click to open to the Eclipse Save Result dialog which allows you to select the project, file name, file type, and export options and save the selected result set to a file within the workspace. Note: This option is unavailable when result sets are displayed in the sash framework. Save All Click to open the Eclipse Save Result dialog which allows you to select the project, file name, file type, and export options and save all of the result sets to a file within the workspace. This option is enabled when you execute multiple SQL statements in a single execution, using the following SQL Editor menu options: Execute All, Execute Select Text (and more than one SQL statement is selected), or Execute Selected Text as One Statement. Export Click to open the Eclipse Export Result dialog which allows you to select the file name, format, and export options and export the selected result set to an external file. This option is unavailable when result sets are displayed in the sash framework. Export All Click to open the Eclipse Export Result dialog which enables you to select the file name, format, and export options and export all of the result sets to an external file. This option is enabled when you execute multiple SQL statements in a single execution, using the following SQL Editor menu options: Execute All, Execute Select Text (and more than one SQL statement is selected), or Execute Selected Text as One Statement. Print Click to open the Eclipse Print dialog which enables you to select the printer, page range, and number of copies to print the selected result set. This button is disabled when result sets are displayed in the sash framework. Print All Click to open the Eclipse Print dialog which enables you to select the printer, page range, and number of copies to print all of the result sets. Teradata Studio Express User Guide, Release 15.12 67 Chapter 4: Query Development Result Set Viewer Icon Option Description This option is enabled when you execute multiple SQL statements in a single execution, using the following SQL Editor menu options: Execute All, Execute Select Text (and more than one SQL statement is selected), or Execute Selected Text as One Statement. The Grid Menu contains: Icon Option Description Hide Column Click to hide the selected column Show All Columns Click to show all columns. Previously hidden columns are also shown. Select Column Click to select the entire column. Auto resize column Click to resize the column to fit the largest cell. Auto resize row Click to resize the row to fit the largest cell. Rename column Click to rename the column header. Find Click to search for a result set data value. Find Next Click to find the next match value in the result set data. Find Next Reverse Click to find the next match value in the result set data in the reverse direction. Aggregates Click to compute aggregates for the selected column values. Filter column Click to create a filter on the column data. Remove filters Click to remove filters for the column. Freeze column Click to freeze scrolling at the selected column. All columns to the left are displayed. All columns to the right are scrolled. To unfreeze, click again. Format Selected Cells Click to open the platform specific Font dialog which enables you to select the font, size, and color (on most platforms) of the selected cells. Copy Cells Click to copy the cell data to the clipboard. The default is to copy the cell data into an HTML table. You can copy cells to Excel, Word, or an email. The Text Display Menu contains: Icon Option Description Copy Click to copy the selected text to the clipboard. The text is copied as a string to the clipboard. Select All Click to select the entire text string displayed. Find Click to search for a result set data value within the text string. Find Next Click to find the next match value in the result set data. Other Actions: 68 Teradata Studio Express User Guide, Release 15.12 Chapter 4: Query Development Result Set Viewer Option Description Sort Column Click the column header. An arrow appears indicated the direction of the sort, ascending or descending order. Clicking a third time returns the column back to its original order. Move Column Select a column and drag it just past the new position. Long Text Display If a cell contains text that exceeds the length specified by the Long Text Boundary Size in the Result Set Viewer Preference, only the first 20 characters of the text is displayed. Double-click the data to display the full text. LOB Display When a result set contains CLOBs (Character Large Objects) or BLOBs (Binary Large Objects), a dialog appears that enables you to indicate whether to save the LOB to a file and the file location, as well as whether to display images in the Result View. Result Set Viewer Preferences The Result Set Viewer Preferences dialog enables you to set display options for result-set data. You can set the following preferences: Option Description Alternating Row Colors Option Display alternate Result Set rows in color — Displays the result set with alternating row background colors. This option can be enabled by selecting the box. You can select a different background color by clicking on the 'color' button. This option is disabled by default. Display alternate Result Set rows in Select the check box to display color in alternate rows of the result set. Click the color color box to open the Color dialog and select a basic color or define a custom color to use. Grid Display Options Show Row Numbers — Displays row numbers. This option is enabled by default. Show Column Headers — Displays column headers. This option is enabled by default. Show Table Grid Lines — Displays lines between rows and columns on the table grid. This option is enabled by default. (*) Display Column Titles rather than Column Names — Displays the column titles (if available) rather than the column names, in the column header area. This option is disabled by default. The query must be rerun in order for a change to this option to take effect. (*) Max Display Row Count — Changes the maximum number of rows to display. The default for this option is 2000. The query must be rerun in order for a change to this option to take effect. Display Null Value as — Changes the value that is displayed when the data is null. The default for this options is "null". Format Options Long Text Boundary Size — Changes the long text boundary size. If a data value length is longer than the long text boundary size, only the first 20 characters are displayed. The user can view the entire data value by doubleclicking the data in the display grid. A pop-up window is presented with the full data value. The default for this option is 150. Table continued on next page. Teradata Studio Express User Guide, Release 15.12 69 Chapter 4: Query Development Result Set Viewer Option Description Display 1000 Separator in Numeric Columns — Displays a 1000 separator in numeric columns. This option is disabled by default. Display Negative Numbers in Red — Displays negative numbers in red. This option is enabled by default. Display Date Format — Changes the date format. This option uses the Java SimpleDateFormat Java Simple Date Format notation to format the date display in the result set. The default for this option is yyyy-mm-dd. Copy Column Delimiter Delimiter Format — Changes the column delimiter when the Copy data option is used on the grid display. The default for this option is Comma Separated. Other possible choices are Tab Separated and User Defined. Delimiter Value — Changes the column delimiter value when the User Defined format option is selected. Copy Include Column Headers — Select to include column headers when the copy data option is used on the grid display. Copy Include Grid Lines — Select to include cell borders when you use the Copy data option to copy cells from the grid display. Viewer Window Options Select the Reuse Result Set Viewer Window check box to cause the Result Set Viewer to refresh the current window with new result sets generated by the SQL Editor. If you deselect the box, the Result Set Viewer creates a new window for each generated result set. Action Buttons Restore Defaults — Restores the default values for the options. Apply — Applies any option changes. This might cause a refresh of the current result sets displayed in the Result Set Viewer. OK — Applies option changes and closes the Preferences page. This might cause a refresh of the current result sets displayed in the Result Set Viewer. Setting Result Set Viewer Preferences Use the Teradata Result Set Viewer preferences to configure views of result-set data. 1. 2. 3. 4. 5. 70 Click Window in the top menu and select Preferences. Expand Teradata Datatools Preferences. Select Result Set Viewer Preferences. [Optional] Under Alternating Row Colors Option, enable the display of an alternate row background color: a) Select the Display alternate Result Set rows in color check box. b) Right-click the color box, and select a color in the Color dialog. c) Click OK. Under Grid Display Options, select the following options as appropriate: Option Description Show Row Numbers Select to show row numbers in the grid display. This option is enabled by default. Show Column Headers Select to show column headers in the grid display. This option is enabled by default. Teradata Studio Express User Guide, Release 15.12 Chapter 4: Query Development Result Set Viewer 6. Option Description Show Table Grid Lines Select to display lines between rows and columns in table grid display. This options is enabled by default. (*) Display Column Titles rather than Column Names Select to display column titles (if available) instead of column names as labels in column headers. This option is disabled by default. (*) Max Display Row Count Specify the maximum number of rows to display. The default value is 2000. Display Null value as Specify the value or string you want displayed when a value results in an empty set or zero value. The default value is null. Note: You must rerun the query to effect any change you make. Note: You must be rerun the query to effect any change you make. Under Format Options, select the following options as appropriate: Option Description Long Text Boundary Type the number of characters allowed for the long text boundary size. Default is 150 Size characters. If a data value length is longer than the long text boundary size, only the first 20 characters display. You can view the entire data value by double-clicking the value in the display grid. The value displays in a new window. 7. 8. Display 1000 Separator in Numeric Columns Select to display a 1000 separator in numeric columns. This option is disabled by default. Display Negative Numbers in Red Select to enable display of negative numbers in red. The options is enabled by default. Display Date Format Specify the format to use to display the date in the result set. Default format is yyyymm-dd. When you specify the format, you must use the Java SimpleDateFormat notation to format the date. See Java Simple Date Format. Under Copy Column Delimiter, in the Delimiter Format field, select how you want columns delimited when the Copy data option is used on the grid display. Option Description Comma Separated Uses commas as delimiters to separate column data (default). Tab Separated Uses tabs as delimiters to separate column data. User Defined Type the delimiter you want to use in the Delimiter Value field. [Optional] Under Delimiter Value, select the following options as appropriate: you want column headers delimited when the Copy data option is used on the grid display. Option Description Copy Include Column Headers Specifies to include column headers as delimited values when the Copy data option is used on the grid display. Copy Include Grid Lines Specifies to include grid lines as delimited values when the Copy data option is used on the grid display. Teradata Studio Express User Guide, Release 15.12 71 Chapter 4: Query Development Result Set Viewer 9. [Optional] Under Viewer Window Options, select Reuse Result Set Viewer Window if you want newly generated result sets to display in the currently open Viewer window. If the check box is not selected, each new result set displays in a separate window in the Result Set Viewer. 10. [Optional] To clear selections and restore default settings, click Restore Defaults. 11. To apply your changes, click Apply. Note: Clicking Apply or OK refreshes the current display of result sets in the Result Set Viewer to correspond with your changes. 12. Click OK to apply your changes and close the Preferences dialog. Results Preferences The Results Preferences provide extended capabilities for exporting results. Option Description Excel Export Options Alternate Row Colors: — Select this check box to alternate row background colors when exporting to Excel. Select a different background color by clicking color. The default for this option is cleared. Big Int/Decimal Format: — Select the output format for Big Integers and Decimals. If you choose number, some precision may be lost. The default for this option is String. Success Sound Select the sound that is played when results are successfully loaded into the Result Set Viewer. The default for this option is no sound. No Sound: — Play no sound when results are successful. System Beep: — Play a system beep when results are successful. Select Sound: — Play a sound file of your choosing when results are successful. Sound File: — Choose a sound file to play when results are successful. Failure Sound Select the sound that is played when results fail to load into the Result Set Viewer. The default for this option is no sound. Success Sound: — Play the same sound as successful results. No Sound: — Play no sound when results failed. System Beep: — Play a system beep when results failed. Select Sound: — Play a sound file of your choosing when results failed. Sound File: — Select the sound file to play when results fail. 72 Restore Defaults Restore the default values for the options. Apply Apply any option changes that have been made. This may cause a refresh of the current result sets displayed in the Result Set Viewer. OK Applies any option changes that you made and closes the preferences page. This may cause a refresh of the current result sets displayed in the Result Set Viewer. Teradata Studio Express User Guide, Release 15.12 Chapter 4: Query Development SQL History View Formatting the Foreground in Selected Cells In the Result Set Viewer you can change the foreground of selected cells. You can reset your selections to default settings by clicking the 1. 2. 3. 4. (Format result set) icon on the toolbar. In the Result Set Viewer, select cells in the result set table. Right-click the selected cells, and select Format Foreground of Selected Cells. Select the foreground options you want for the selected cells. Click OK. The foreground changes you select are applied to the selected Result Set Viewer cells. Formatting the Background in Selected Cells In the Result Set Viewer you can apply background formatting to selected cells in the result set table. You can reset your selections to default settings by clicking the 1. 2. 3. 4. (Format result set) icon on the toolbar. In the Result Set Viewer, select cells in the result set table. Right-click the selected cells, and select Format Background of Selected Cells. Select the background color you want for the selected cells. Click OK. The background color changes are applied to the selected Result Set Viewer cells. SQL History View SQL History Form The SQL History form provides an enhanced display of the history information. As you execute SQL statements from the SQL Editor or run functions from the Data Source Explorer, an entry is added to the SQL History list. The history displays extensive information about each SQL execution. It includes execution elapsed time, DBMS time, fetch time, database server, row count, parameter display for macros and stored procedures, SQL statement, and SQL statement type. The SQL History form displays the data in a grid format that lets you select rows or cells. It provides options to copy cells or rows, sort columns, delete rows, edit the note or SQL for a history entry, filter columns, search for result history data, format the display, and re-execute SQL statements. The SQL History uses an embedded Derby Database to manage the SQL History entries. If you close the form and need to re-open it, go to Window > Show View > Other > SQL History. You can add notes manually by clicking on the Note column value. You can also choose to be prompted to add notes when you execute the SQL. Set the Prompt for notes option using the SQL Handling preferences. You can sort columns in ascending and descending order with the exception of the Parameters column. For single column sorting, left-click the mouse button. For multi-column sorts, note the following: • Columns are movable and re-sizable. Many of the columns are grouped together under a collapsible header. • Rows can be selected by clicking in the numbered row header. Teradata Studio Express User Guide, Release 15.12 73 Chapter 4: Query Development SQL History View • Column order, collapsed columns, filter, sort, and formatting are preserved from session to session. • If a filter is in effect, the result of a newly executed SQL statement is inserted as the top row, regardless of whether it meets the filter criterion. If a sort is in effect the new entry is inserted in the sorted order. • The Result column contains a summary of the executed SQL operation. To read the entire contents in a column cell, hover the mouse pointer over the cell. Error results show as red text in the resulting tool tip display. The following examples are samples of the Result summary. • Example 1: In this example a single statement was executed successfully. Executed as Single statement. >Elapsed time = 00:00:00.108 STATEMENT 1: Select Statement completed. 26 rows returned. associated • Example 2: In this example the executed statement failed. This statement also has this icon with it. Executed as Single statement. Failed [3807 : 42S02] Object 'bogus' does not exist. Elapsed time = 00:00:00.145 STATEMENT 1: Select Statement failed. • Example 3: In this example the executed statement was canceled. This statement also has this icon associated with it. Executed as Single statement. Canceled. Elapsed time = 00:00:00.000 STATEMENT 1: Select Statement canceled. Toolbar Actions Icon Option Description Delete Selected Rows Deletes selected row(s) from the view and history database. Filter history display Opens a dialog to filter the display. Export history Opens a dialog to export history view items to XML file. Import history Opens a dialog to import history items from either a previously exported XML history file or SQL Assistant history file. Cleanup history Opens a dialog to clean up SQL history records based on selected criteria. Format History View Enables you to format the display. The platform-specific Font dialog allows you to select the font, size, and color (on most platforms). Sort history display Opens a dialog for setting a multi-column sort. Toolbar Menu Options Icon Option Description Delete Selected Rows Deletes selected row(s) from the view and history database. Export history Opens a dialog to export history view items to an XML file. Import history Opens a dialog to Import history items from either a previously exported XML history file or SQL Assistant history file. Table continued on next page. 74 Teradata Studio Express User Guide, Release 15.12 Chapter 4: Query Development SQL History View Icon Option Description Cleanup history Opens a dialog to clean up SQL history records based on selected criteria. Clear Filter Removes the current filter from the display. Filter Opens a dialog to filter the display. Format History View Enables you to format the display. The platform specific Font dialog displays to allow you to select font, size, and color (on most platforms). Sort multiple columns Opens a dialog for setting a multi-column sort. Context Menu Options: Icons Option Description Find Allows you to search the SQL History view for a value. Find Next Finds the next matching value in the history view. Copy Row Copies the selected row(s). Rows are copied as text and as HTML. The HTML display preserves the column headers. The target to which you paste determines whether text or HTML displays. Copy Cells Copies the cell data to the clipboard. Delete Row Deletes selected row(s) from the view and history database. Edit SQL Edits the SQL from a selected cell in the SQL Statement column in an SQL Editor. Edit Note Edits the note from a selected cell in the Note column. Reexecute statement Re-executes the SQL from the selected cell in the SQL Statement column. About SQL History Form The SQL History view provides information about SQL/DDL executions on one or more databases in your system. As you execute SQL/DDL statements from the SQL Editor or run functions from the Data Source Explorer, an entry is added to the SQL History list. Teradata Studio Express User Guide, Release 15.12 75 Chapter 4: Query Development SQL History View Toolbar The SQL History toolbar contains actions and menus that help you manage the data in the history data grid. Numbered Rows The first column contains numbers assigned to each rows in the data grid. The numbers start with 1 and increment for each data entry. The numbers do not indicate a special ordering or structure to the history data. Use them as an easy way to refer to rows in the grid. To select an entire row, click the number for the row. You can then right-click and select an action to perform on that row. For example, you might select several rows and then right-click to select Find to search for specific data in those rows. Column Header Row The top row of the history grid contains the column headers for the categories of data collected during each SQL/DDL execution. SQL History Data Grid The SQL History view uses a data grid format of rows and columns to display information for each SQL/DDL execution. The grid displays each history entry in a single data row. Column headers in the top row distinguish the types of data collected during each execution. Toolbar for SQL History The SQL History toolbar contains icons and menus to help you manage the SQL History view and display of history records. Actions such as Delete Rows and Delete All History, in addition to removing records from the view, delete the records in the SQL history database. Actions Click toolbar icons to perform tasks. You also can access actions from the menu drop-down ( right-end of the toolbar. Option ) at the Icon Label Description Delete Row Deletes selected rows from the view and SQL history database. Filter Opens the History Filter dialog to select criteria for filtering data in the view. Clear Filter Resets filter by removing filter criteria and showing all history entries in the view. Export History Displays the Export History dialog to export SQL history records to an XML file. Table continued on next page. 76 Teradata Studio Express User Guide, Release 15.12 Chapter 4: Query Development SQL History View Option Use the Minimize Icon Label Description Import History Opens the Import History dialog to import SQL history entries from an exported XML history file or SQL Assistant history file. Cleanup History Opens the Cleanup History dialog to clean up SQL history records using the criteria you specify. Sort Opens the Sort dialog to choose which columns you want sorted. and Maximize icons at the far right to resize the SQL History view. Cleanup History The Cleanup History dialog enables you to delete SQL History records based on selected criteria Option Description Delete SQL History using a criteria Enables you to delete records based on the following criteria: • • • • • • • Date deletes records from the SQL History view when the Timestamp column value is less than the selected date. Source deletes records from the SQL History view when the Source column matches the entered value SQL Statement deletes records from the SQL History view when the SQL Statement column is a super set of the entered value. Notes deletes records from the SQL History view when the Notes column is a super set of the entered value. User ID deletes records from the SQL History view when the User ID column matches the entered value. Queries that failed deletes records from the SQL History view when the query execution failed. Rows with empty Notes deletes records from the SQL History view when the Notes column value is empty. Delete duplicate queries in SQL History Deletes duplicate SQL query records from the SQL History view. Compact unused disk space allocated by SQL History Releases allocated disk space not used by the SQL History view. After the command executes, you must restart the application to make the disk space available. Import History The Import History dialog enables you to import history view items from either a previously exported XML history file or from an SQL Assistant MDB or XML file. Teradata Studio Express User Guide, Release 15.12 77 Chapter 4: Query Development Filtering with Data Filter Option Description Source Type Select either an XML file created using the Export history option or an SQL Assistant history MDB file. File Name Enter the name of the file from which to import the history items. Browse Select a folder and file name. Note: The import of an SQL Assistant MDB file is only available on the Microsoft Windows 32-bit platform. To locate the SQL Assistant history MDB file, start SQL Assistant and click Tools > Options and select Locating File Paths for the history file. Export History The Export History dialog enables you to save SQL History view items to an XML file. You can select to export all or specific items from the view. Option Description File Name Displays the name of the XML file to which history entries are saved. Browse Opens a dialog to select the location and file name of an XML file on the file system. History Filter All Saves all history view items to an XML file. History Filter Selection Saves only selected row items. You can select single or multiple rows from the history view. Filtering with Data Filter Use the Data Filter feature to set filter rules that reduce the number of rows loaded into the Table Data Editor. Data Filter icon. 1. From the Table Data Editor, click 2. In Filter, select a filter operator from the list and type a valid value or character string. For example, if values in Column2 are type VARCHAR, and you filter to display only rows LIKEproduct2, the Table Data grid refreshes to show all rows with the value product2 in the data string. 3. [Optional] If you want to clear all rules and set new filters, click Clear All. 4. Click OK to show filter results based on your filter rules. Note: The SYSUDTLIB database always shows in the filtered list. 5. When asked to confirm, click OK. Note: 78 Teradata Studio Express User Guide, Release 15.12 Chapter 4: Query Development Filtering with Data Filter If you want to redo the filter results, click Revert in the toolbar, change the filter rules in the Data Filter, and then click OK. You can repeat these steps as often as you like. History Preferences Exclude Options for History Database Select one or more of these options to exclude in the Teradata SQL History database: Option Description Exclude Explain Statements Check this box to exclude EXPLAIN statements in the History database. Exclude Unsuccessful Queries Check this box to exclude unsuccessful queries from being entered in the History database. History Rows In Limit History View Rows, type the maximum number of rows allowed to display in the Teradata SQL History view. History View Columns Settings Use action buttons to select and move columns between the Selected Columns panel and the Available Columns panel. Column Actions Description Remove Removes the column you select from the Selected Columns list. Remove All Removes all columns shown in the Selected Columns list. Add Moves a column from the Available Columns list to the Selected Columns list. Add All Adds all columns in the Available Columns list to the Selected Columns list. Move Up Moves a selected column one position up in the list. Move Down Moves a selected column down one position in the list. Column Options Description Timestamp Date and time at which the query ended Source Data source name User ID User ID logged on Destination TBW - in progress Result Result message which is blank unless an error occurs. To see full message, hover your mouse over a cell in the Result column. Row Count • Teradata Database — number of rows matching the query submitted. If you abort a query in progress or decline to continue after the output limit is reached, Rows shows only how many rows matched the query you submitted. Table continued on next page. Teradata Studio Express User Guide, Release 15.12 79 Chapter 4: Query Development Database Objects Search Column Options Description • Other databases — number of rows returned or changed. If you abort, Rows shows only the number of rows returned. Note User note attached to query SQL Statement Query text SQL Type Type of database accessed Length Length of the query in characters Statements Number of statements in the query Statement Type List of statement types used in the query, such as, CREATE TABLE, INSERT, SELECT. Elapsed Time Total elapsed time for the query DBMS Time Time spent within the database Fetch Time Time taken to return the data Parameters Number of parameters used in the query Sequence Order in which the query was submitted to the database Actions Option Description Apply Click to apply your changes. Restore Defaults Click to return settings to default values. OK Click to save your preference settings. Database Objects Search Find Object Find Object Find Object ( ) enables you to find a database object in the Data Source Explorer that matches a certain text value. It begins the search from the point selected in the Data Source Explorer and returns the first object whose name matches the text pattern. Note: The search is not case sensitive. Find Next Find Next ( ) finds the next database object of the same object type that matches the text value, expands it, and selects it in the Data Source Explorer. 80 Teradata Studio Express User Guide, Release 15.12 Chapter 4: Query Development Database Objects Search Option Description Search Value Specifies a value to search for. You can use the database 'LIKE' syntax to provide a more expanded search. The 'LIKE' syntax includes a percent sign ('%') and low line character ('_' ). The percent sign character represents any string of zero or more arbitrary characters. The low line character represents exactly one arbitrary character. For example, the search value of 'emp%' finds the first object whose name starts with 'emp'. Note: You must use the backward slash character '\' as the escape character when entering the special search characters, '\', '_', and '%', in your search value. For example, 'emp\%' searches for the first object whose name equals 'emp%'. Object Type Selects the object type from the list of object types for which you want to search. Find Starts the search process. Advanced Find Opens the Advanced Find dialog. Reset Resets the Search Value to an empty field and the Object Type for the selected location in the Data Source Explorer. Finding Objects You can search for database objects in the Data Source Explorer that have names that match a text string you specify. 1. From the Data Source Explorer, right-click the database or user in which you want to search for an object. 2. Click Teradata > Find Objects. The Find Object dialog opens. 3. For Search Value Enter the exact name of the object you wish to find. The search is case-insensitive. If you know or wish to enter only a portion of the object name, click Advanced Find to open the Advanced Find dialog where you can specify only a portion of the object name in your search criteria. 4. Use the Object Type list to specify the type of database object you are searching for. If you wish to search more than one object type, click Advanced Find to open the Advanced Find dialog where you can specify several types of objects to search. 5. Click Find. • If you used the basic Find Object dialog box to search, the Data Source Explorer tree expands to show you the first instance of an object it finds matching your criteria. You can press F3 or right-click the Data Source Explorer tree and click Teradata > Find Next to search for other objects that have the same name. • If you used the Advanced Find Objects dialog box to search, all results of the search are displayed in a tab of the Object Viewer. Teradata Studio Express User Guide, Release 15.12 81 Chapter 4: Query Development Database Objects Search Advanced Find Objects The Advanced Find Object ( ) feature enables you to find all database objects that match a certain text pattern. It searches the referenced Connection Profile for objects names that match the text pattern. The Advanced Find Objects feature uses the Teradata Dependency Browser to perform the search for each object type selected in the dialog. Option Description List of Databases or Connection Profiles available for the search If you opened Advanced Find Objects dialog from the Databases Folder, a list of databases for the given Connection Profile appears. If you opened the Advanced Find Objects dialog from the Advanced Search button in the simple Find Object dialog at the highest level in the Data Source Explorer, the list of Connection Profiles appears. You can use the arrows to move single selected items to or from the list of objects to be searched. The double arrows allow you to move all available objects to or from the list to be searched. Search constraint The Find Objects feature uses the search constraint to build a search pattern out of the search value and pass it on to the Teradata Dependency Browser. Note: You must use the backward slash character '\' as the escape character when entering the special search characters, '\', '_', and '%', in your search pattern. The '_' (low line) character represents exactly one arbitrary character. The '%' (percent sign) character represents any string of zero or more arbitrary characters. Types of search constraint are as follows: 82 Search Option Description Starts with the characters Search value is appended with a '%' character. Ends with the characters Search value is prepended with a '%' character. Contains the characters '%' character is added to the begging and end of the search value. Anonymous Name Search Searches for anonymous or empty name values. Anonymous names are valid only for Primary Key, Foreign Key, Check Constraint, and Index names. All other object type name options are disabled. Enter a valid SQL search pattern Use for a custom search pattern. The search pattern follows the standard database search pattern as used for the Teradata 'LIKE' option pattern match. For example, if you want to search for all names that have exactly one character after the word 'cust', the custom pattern would be 'cust_'. Or if you want to search all names that match Teradata Studio Express User Guide, Release 15.12 Chapter 4: Query Development Database Objects Search Option Description Search Option Description 'sales100%', then the search pattern would be 'sales100\%'. Note: Use the '\' as the escape character when entering the special search characters, '\', '_', and '%', in the search pattern. Search Value The text value to search for. Limit size of search result to: The limit to the size of the search result list. Valid values are between 1 and 500. Object Types Names you want to compare with the search value. This list is dependent on where in the Data Source Explorer tree you invoke the Find Objects dialog. For example, if you selected a Stored Procedures folder, the Stored Procedure Name and Parameter Name object type options display. Select All Selects all of the Object Type names presented. Clear All Clears all of the Object Type names presented. Advanced Find Results The find results are displayed in the Find Results tab in the Object Viewer. The tab shows a list of the objects found that match the search pattern in the Advanced Find Objects dialog. The list displays as a table grouped by object types: • • • • • • Tables Macros Stored Procedures User Defined Functions User Defined Types Views Within each object type category, it is further grouped by sub-element, such as: • • • • • Columns Constraints Triggers for Tables Parameters for Macros and Stored Procedures Columns for Views Find Results The Find Results dialog provides a list of the objects found that matched the search pattern entered in the Advanced Find Objects dialog. The list is displayed as a table grouped by object types and within each object type category further grouped into details. Teradata Studio Express User Guide, Release 15.12 83 Chapter 4: Query Development Showing Table Row Counts Showing Table Row Counts You can show the row count in one or more Teradata Database tables. 1. From the Administration perspective, select a database in the Navigator. A list of available objects display in the Object List Viewer. 2. Click to highlight one or more tables in the Object List Viewer and do one of the following: • From the toolbar, click . • Right-click an object and select Row Count. A list of the selected tables with their row count displays in the Row Count(s) property form. 84 Teradata Studio Express User Guide, Release 15.12 CHAPTER 5 Table Data Development About the Table Data Editor The Table Data Editor is an advanced editor for viewing and editing table data stored in a Teradata Database or Teradata Aster Database. The editor can manage any size table including very large tables that contain thousands of rows of data. You can also export table data to a file, such as Microsoft Excel, for further review. You can insert, delete, and update data in a table, and then filter to see the rows that have changed due to your edits. You can also set filter rules on table columns to show only data of interest. For ease of access and viewing, the Table Data Editor organizes data rows into pages that you select using page controls in the toolbar. The default is 500 rows per page, but you can define a preferred page size at the top of the editor. Toolbar The Table Data Editor toolbar contains navigation aids and action buttons that help you manage, filter, and edit data in a database table. Column Header Row The top row of the Table Data Editor shows the labels and data types for the table columns. Numbered Row Column Teradata Studio Express User Guide, Release 15.12 85 Chapter 5: Table Data Development Table Data Editor You can show or hide the first column by setting your preference in the Table Data Editor Preference dialog. The column shows row numbers for the table you are editing. Table Data Grid The Table Data Editor displays rows and columns of a database table in a spreadsheet grid format that shows relationships of data in the table. To update and see the most current view of this data, click Refresh in the toolbar. Status Bar This area displays error and system messages. Table Data Editor The Table Data Editor enables you to work directly with data stored in tables in a Teradata Database or Teradata Aster Database. The editor interface is a table grid of columns and rows that displays the corresponding data columns and rows of the selected database table. You can right-click rows and columns to view the actions you can perform on data. You can resize column and row widths by dragging line separators for column and row headers. Toolbar Use the toolbar to page to specific rows and to set the number of rows per page. You can also use the toolbar to save, filter and sort, revert, export, and refresh data. Table Data Grid The Table Data Editor displays a grid of columns and rows. The grid rows and columns correspond to the rows and columns in the table you selected from the Data Source Explorer tree. If the table you selected contains a large number of rows, the editor automatically creates data pages which you can size using the Page Size field in the toolbar. The default is 1000 rows per page. Actions on Columns Right-click a column header and select an option in the list. 86 Option Description Hide columns Hides a column from the Table Data grid. The column in which you rightclicked to select this option is the column that is hidden. To undo the hide, select Show all columns. Show all columns Causes any hidden columns to re-display in the Table Data Editor. Auto resize column Changes the column width back to the auto-set width. Find/Replace Opens the Find/Replace dialog in which you can enter keywords to search data. Show Values Opens the Show Values dialog in which you can specify filter rules and show only rows that meet those rules. To undo a Show Values filter result, select Reset Show Values. Reset Show Values Resets rows to the order that existed prior to the Show Values filtering of the column data. Teradata Studio Express User Guide, Release 15.12 Chapter 5: Table Data Development Table Data Editor Actions on Rows Right-click a row or cell and select an option from the list. Option Description Auto resize now Resizes rows back to the auto-set height. Copy Copies one or more rows in the table for pasting to a data spreadsheet file; for example, Microsoft Excel. Insert Inserts a row in the table. Revert Reverts the rows you select by undoing your changes to that row. You are prompted to confirm the operation. Click OK to revert. Delete Deletes the rows you select. Deleted rows are highlighted. To undo a row deletion, select the row and next select Revert. Select Rows for Export Selects rows for export by placing an Export icon in all selected rows. The icon is aligned left in the first column of the row. Clear Rows for Export Deselects rows for export. The change is indicated by the removal of the Export icon in the first column of the row. Clear All Selected Rows for Export Resets all rows previously selected for export. The Export column disappears. Export Selected Rows Opens the Export Data dialog to export all data rows selected for export. Rows selected for export are marked by an Export icon in the first column. icon is the first Actions on Cells Right-click a table cell and select an option from the list. Option Description Undo Undoes the last change. Cut Removes the data from one or more selected table cells and retains for pasting to a different cell. Copy Copies data you want to paste to a data spreadsheet file; for example, Microsoft Excel. Paste Pastes data from the clipboard into selected table cell. Delete Deletes the data in the cell. Status Bar The status bar at the bottom of the gird shows errors and Save status for the Table Data Editor. Toolbar The Table Data Editor toolbar contains navigation aids and action buttons that help you manage, find, and edit the data in a database table. Teradata Studio Express User Guide, Release 15.12 87 Chapter 5: Table Data Development Table Data Editor Table Navigation Use the following features to navigate to specific rows in a large table. Option Description Row Type the row number to display at the top of the table data grid. Use the dropdown menu to select a recent row number. of Shows the number of data rows in the table. You cannot edit this field. Page Size Select the number of rows to include per page from the drop-down list. For example, if you select 1000, the first page begins at 1, and the second page begins at 1001. The default page size is 500. Actions Click toolbar icons to perform tasks. Option 88 Icon Label Description Select First Page Goes to the first page of table data pages. Select Previous Page Displays next page. Select Next Page Displays previous page. Select Last Page Goes to last page of table data pages. Save Commits data changes to the database. You can view the SQL DDL statement in the SQL Preview view before you click the Save icon. Filter by Edits Displays the Show Edits dialog. SQL Preview Displays the SQL Preview dialog to view generated SQL. Revert Reverts values back to pre-edit states. Data Filter/Sort Displays the Data Filter dialog to specify filter and sort data rules. Export All Displays the Export Data Wizard which exports all data. Refresh Refreshes table data list from data in the database. Teradata Studio Express User Guide, Release 15.12 Chapter 5: Table Data Development Table Data Editor About Editing Large Data and Objects The Table Data Editor provides editing capabilities for large data and large object storage in a database. You can edit: • Binary Large Object (BLOB) - Contains raw binary data stored as a single object. BLOBs are used to store images, video clips, and word documents. See Editing Binary Large Object Data. • Character Large Object (CLOB) - Contains only plain text, same as VARCHAR data type, and is used to store simple text, HTML, or XML documents. CLOBs are considered a subset of BLOBs since character data is a sequence of bytes and can be stored in BINARY fields as well as CHAR fields. See Editing Character Large Object Data. • Large Binary Data - Contains raw binary data stored as VARBYTE data type. See Editing Large Binary Data. • Large Text Data - Contains character data stored as VARCHAR data type. See Editing Large Text Data. • XML Data Type - Contains data in the eXtensible Markup Language (XML) format. See Editing XML Data. About Paging Large Tables The toolbar in the Table Data Editor contains several features that enable you to specify how many rows are included in a page, and to move forward and backward through pages to locate data. Use the Page Size field to specify the number of data rows you want included in a page. To review data in a table, use the page arrow keys to move to the beginning or end of the table, or incrementally forward or backward one page at a time. Data Filter The Data Filter dialog enables you to define data filters for the Table Data Editor. Use filtering to reduce the number of rows loaded into the Table Data Editor and to display only data of interest. You can determine which data displays by: • Sorting column order • Filtering on data values within columns Filter Tab Move column names from the Table Column list to the Sort Column list to indicate on which columns to sort to display data in the Table Data grid. Option Description Column Names Lists names of columns in table. Types Lists data type for each column in Column Names. Select By Select a filter operator from the list and type a valid value or character string. For example, if values in Column1 are type INTEGER, and you filter to Teradata Studio Express User Guide, Release 15.12 89 Chapter 5: Table Data Development Table Data Editor Option Description display only rows greater than (>) 5999, the Table Data grid refreshes to show all rows with the value 6000 or above. Sort Tab Use fields and radio buttons in this section to indicate how you want columns sorted. Option Description Table Columns Lists all columns by name in the table. Ascending Orders the Table Columns list from the smallest or lowest to the largest or higher value. For example, A to Z or 1 to 100. Descending Orders the Table Columns list from the largest or higher value to the smallest or lowest value. For example, Z to A or 100 to 1. Sort Columns Lists one or more columns in the order on which to sort. Up Select a column in the Sort Columns list and click Up to move it up in the list order. Down Select a column in the Sort Columns list and click Up to move it up in the list order. Actions Use the action buttons at the bottom of the dialog to clear or save your settings. Option Description Clear All Click to revert all selections in the Select By column to the default None. OK Click to save your Filter and Sort settings. Opening the Table Data Editor The Table Data Editor gives you the ability to manage data stored in Teradata databases. Begin by using the Data Source Explorer view to find the table object you want to review or modify. 1. Open the Data Source Explorer view (Window > Show View > Data Source Explorer). 2. Navigate to the table you want to review or modify. 3. Right-click the table object and select Data > Edit Data. The Table Data Editor opens in the right pane and displays the data in the table you selected. You can also open the Table Data Editor from the Data Lab view. 1. Open the Data Lab view (Window > Show View > Data Lab View). 2. Navigate to the table you want to review or modify. 3. Right-click the table object and select Edit Data. Table Data Editor Preferences Set preferences to determine how the Table Data Editor displays. You can set these features: 90 Teradata Studio Express User Guide, Release 15.12 Chapter 5: Table Data Development Table Data Editor • • • • Show or hide numbered row column header Background color for alternate table rows Highlighted row color for inserted, updated, and deleted data Thresholds for filter and transaction rows Color Options To control color, choose from these options: Option Description Display alternate Result Set rows in color Select the check box to enable an alternate row background color, and then select the color. Click the color box to see color options. Insert Selection Color Click the color box to select the background color for inserted data. Update Selection Color Click the color box to select the background color for updated data. Delete Selection Color Click the color box to select the background color for deleted data. Editor Options To set edit preferences, choose from these options: Option Description Show Row Numbers Select the check box to show numbered rows in the first column of the data grid. Display Filter Dialog Threshold (rows) Enter the number of table rows above which the Table Data Editor presents the Data Filter dialog. Be sure to specify filters in the Table Data Editor to reduce the number of data rows that display. The default is 500000. Transaction Commit Size (rows) Enter the number of data rows to batch in a single COMMIT transaction. This number is the threshold at which the batch UPDATE operation occurs. For example, if you set the threshold at 1000, the operation batches 1000 data row updates in a single COMMIT transaction. The default is 500. Copy and Paste Options To set copy and paste preferences, choose from these options: Option Description Copy Column Names when Copying Select the check box to include column header labels when copying data to a Rows file. Column Delimiter Select from the list the type of delimiter to use to separate data when copying or pasting from the editor to a file, such as Microsoft EXCEL or Notepad. Supported delimiters are: Tab (default), Comma, Semicolon, and Space. Actions Apply, restore, or save your settings by choosing from these options: Option Description Apply Click to apply your changes. You can preview results in the Table Data Editor. Restore Defaults Click to return to default values. Table continued on next page. Teradata Studio Express User Guide, Release 15.12 91 Chapter 5: Table Data Development Table Data Editing Option Description OK Click to save your preference settings. Setting Table Data Editor Preferences You can set preferences that determine the appearance and functional behavior of the Table Data Editor. You can accept the defaults or select new settings. 1. 2. 3. 4. Select Window > Preferences in the main menu. Expand Teradata Datatools Preferences and select Table Data Editor Preferences. Make any desired changes to the Table Data Editor Preferences. Click Apply to apply your changes. You can preview results in the Table Data Editor before you click OK. 5. After previewing, if you want to return to default values, click Restore Defaults. 6. Click OK to save your preference settings. Table Data Editing About Editing Table Data The Table Data Editor enables you to edit data stored in tables in a Teradata or Aster database. The editor supports very large tables and provides several additional editors for large data objects such as Character Large Objects (CLOBs) and Binary Large Objects (BLOBs). It also supports an XML Data Type Editor for editing XML data. Rows of data can be grouped into pages that allow you to quickly locate table rows. Advanced filter and sort functions in the Data Filter help you to easily find data of interest. You can edit table data either directly in the Table Data Editor or you can export data to a Microsoft Excel spreadsheet or text file to change the data and then import it back into the table using the Load Data Wizard. Use the toolbar functions at the top of the editor to export data. Editing data in the Table Data Editor is as simple as editing data in a spreadsheet editor. Insertion and deletion functions are similar, as well as keyboard and cursor actions. Editing Table Data The Table Data Editor enables you to update data in a database table by: • Inserting table data. • Deleting table data. • Reverting table data. In addition, it also provides several editors for large data tables. Editors include: • • • • 92 CLOB Editor BLOB Editor Large Binary Editor Large Text Editor Teradata Studio Express User Guide, Release 15.12 Chapter 5: Table Data Development Table Data Editing • XML Data Type Editor Inserting Table Data You can insert rows in a table. 1. Right-click on a row or in the Table Data grid. 2. Select Insert. 3. Enter data in the new row at the bottom of the table. 4. Click in the toolbar to save your changes. You can undo an insertion by clicking selecting in the toolbar. or right-clicking the row or in the Table Grid and Revert. If you want to revert more than one row at the same time, select multiple rows and click Revert. Displaying Column Data by Value You can specify to show values by columns. 1. Right-click in the column header of the column in which you want to show specific values. 2. Select Show Values. 3. In the Show Values dialog, select from one of the two steps below as the options are different based on the data type of values in the selected column. 4. To show values for DECIMAL, FLOAT, INTEGER, SMALLINT, BYTEINT, BIGINT, TIME, TIMESTAMP, or DATE data types, select from these options: Option Description Show Values Equal with Type a numeric value to match against column data values that are equal to the value you enter. Show Values Greater than Type a numeric value to match against column data values that are greater than the value you enter. Show Values Less than Type a numeric value to match against column data values that are less than the value you enter. 5. To show values for the VARCHAR data type, select from these options: Option Description Show Values that Start with Type a value to match against the initial characters of a data value in the selected column. The field supports alpha-numeric characters. Do not use special characters or wildcards. Show Values that End Type a value to match against the end characters of a data value in the selected column. with The field supports alpha-numeric characters. Do not use special characters or wildcards. Show Value that Contains Type the value you want to match against characters contained in data values in the selected column. The field supports alpha-numeric characters. Do not use special characters or wildcards. 6. Click OK. Teradata Studio Express User Guide, Release 15.12 93 Chapter 5: Table Data Development Table Data Editing Deleting Table Rows You can delete entire rows of data in a table. For information about deleting data in cells, see Deleting Data from Cells. 1. Select a table row. The row background color changes when you select it. 2. Right-click and select Delete. The row is marked for deletion from the table. 3. Click in the toolbar to save your changes. You can undo a deletion by clicking in the toolbar or right-clicking the row and selecting Revert. Deleting Data from Cells You can right-click a table cell to display the Delete option. The Delete function deletes only data in a cell, and does not delete the selected table cell. 1. Select a table cell. The cell background color changes when you select it. 2. Right-click and select Delete. 3. Click in the toolbar to save your changes. Reverting Edits You can reset data to pre-edited values by clicking the Revert icon ( ) in the toolbar. When you revert data, all unsaved changes are discarded, and any edited data is reset to its last saved value. 1. Click the Revert icon ( ) in the toolbar. 2. Confirm that you want to revert the contents of your data sheet by clicking OK. The Table Data Editor refreshes and shows the data reset to pre-edited values. Finding and Replacing Data You can find specific data values in a table column and replace it with a different value. You cannot replace values across columns in a table. 1. Right-click in the column header of the column that contains the data you want to find and replace. 2. 3. 4. 5. Select Find/Replace. In Find, type the value you want to find. In Replace With, type the value you want to replace the found value with. [Optional] Under Options, select these check boxes: Option Description Case Sensitive Select to find only case-exact matches. 94 Teradata Studio Express User Guide, Release 15.12 Chapter 5: Table Data Development Table Data Editing Option Description Wrap Search Select this option if you want the search to return to the top of the column after it reaches the bottom. If you do not select this option and begin your search in the middle of a column, the search only does an incremental Find for half of the column and stops. 6. Click to select an action: Option Description Find Click to perform an incremental find of the value you entered in Find above. Replace Click to replace an incremental Find value with the value you entered in Replace above. Replace All Click to replace all Find values at the same time. 7. Click Close to return to the Table Data Editor. Find Replace The Find Replace dialog lets you find specific data values in a table column and replace them with a different value. You cannot replace values across columns in a table. You can: • Search for specific data values in tables. • Replace target values with new values. • Replace all values at the same time or incrementally one by one. Find/Replace Values You specify a data value to find and which value you want to replace it by completing these fields: Option Description Find Type the data value you want to find. The data type must be consistent with the data type of the selected column. To perform only a Find operation, click Find at the bottom of the dialog. The Find operation looks for the value in the data column in which you opened the Find/Replace dialog. Replace Type a data value to replace the value in Find. The data type must be consistent with the column data type. To perform the Find/Replace operation, click Replace at the bottom of the dialog. Find/Replace Criteria As an option, you can specify additional criteria for a Find/Replace operation by selecting the following check boxes: Option Description Case Sensitive Select to find only case-exact matches. Wrap Search Select this option if you want the search to return to the top of the column after it reaches the bottom. If you do not select this option and begin your search in the middle of a column, the search only does an incremental Find for half of the column and stops. Actions Select an action from these options to perform Find and Replace operations. Teradata Studio Express User Guide, Release 15.12 95 Chapter 5: Table Data Development Large Data and Objects Editing Option Description Find Click to perform an incremental find of the value you entered in Find above. Replace Click to replace an incremental Find value with the value you entered in Replace above. Replace All Click to replace all Find values at the same time. Close Click to return to the Table Data Editor. Selecting to Filter by Edits After you modify data in a table, you can select to view only the edited data rows. Filters are available for updated, deleted, or inserted data. This feature is useful if you've made multiple changes in a large table and want to review your changes before updating them in the database. It can also be used to group changes for export to a file, either as a record or for later review. 1. With an edited table open in the Table Data grid, click the Filter by Edits icon in the toolbar. The Show Edits dialog opens. 2. Select which type of edit to display by checking one or more of these options: a) Select the Inserts check box to display any rows with newly inserted data in the table. b) Select the Updates check box to display rows in which data has been added, edited, revised, or deleted. c) Select the Deletes check box to display rows removed from the table. 3. Click OK. The Table Data Editor refreshes to show only table rows that match the filter options you selected. Viewing SQL Preview for Data Updates After you make an edit, you can preview the generated SQL DDL statements. The SQL DDL statement includes updates and other changes that are submitted to the database when you save your changes. 1. Make one or more edits in the Table Data Editor. 2. 3. 4. 5. Click the SQL Preview icon in the toolbar. Review the generated SQL in the SQL Preview text box. If you find an incorrect data update, return to the Table Data Editor and make further edits to correct it. Click Close to return to the Table Data Editor view. Large Data and Objects Editing About the Blob Editor You can use the Table Data Editor to review and edit database tables that contain Binary Large Objects (BLOBs). A BLOB is a collection of binary data stored as a single entity in a Database Management System 96 Teradata Studio Express User Guide, Release 15.12 Chapter 5: Table Data Development Large Data and Objects Editing (DBMS). BLOBs are typically images, audio, or other multimedia objects, though sometimes binary executable code is stored as a BLOB. You must edit BLOBs in the Blob Editor. Source of Imported Data If the data in the object is imported, the source file for that data displays in the File field. Actions on Object You can import, export, or clear the binary data in BLOBs. These functions are selected by clicking the action buttons to the left of the editor workarea. Editor Workarea The editor workarea displays the current data for the object you selected to edit. You can insert, delete, and modify data displayed in this area. You can also import from or export to files such as a text file. To remove all data displayed in the editor workarea, click Clear. Note: You can view, import, and export data larger than 64k, but you cannot edit the data. Imported data that is larger than 64k is identified by its filename in the editor. Slidebars Teradata Studio Express User Guide, Release 15.12 97 Chapter 5: Table Data Development Large Data and Objects Editing The data in an object is often more than can be displayed within the editing area. Use the slidebars on each side of the workarea to scroll through data. Blob Editor The BLOB Editor displays the binary data contained in the selected Binary Large Object (BLOB) stored in a database. You can edit the data in the BLOB by: • • • • • Inserting binary data Deleting binary data Clearing the binary data in the object Importing binary data from a file Exporting the binary data in the object A BLOB data object can be represented in one of three ways: • BLOB handle - Handle to the BLOB data in the database. • Snippet of data - Text snippet you edit or insert in cell. • Filename - For data objects over 64k, name of file that contains the data. You can edit or insert data in this file. BLOB data larger than 64k cannot be edited in the Blob Editor. Edit Blob Value Use the Blob Editor to modify the binary data in the Binary Large Object (BLOB) that you selected from a BLOB table. Option Description File If data is imported, shows the name of the import source file. Editor Workarea Displays the binary data in the selected object. Actions Use the action buttons to the right of the editor to import, export, or clear binary data. Option Description Import Click to import binary data from a file. Export Click to export the binary data displayed in the editor to a file, such as a binary data file. Clear Click to remove all data displayed in the editor workarea. OK Click to save the data to the object. Opening the Blob Editor You open the Blob Editor from the Table Data Editor by selecting the row that contains the Binary Large Object (BLOB) in the table. A BLOB data object can be represented in one of three ways: • BLOB handle - Handle to the BLOB data in the database. • Snippet of data - Text snippet you edit or insert in cell. 98 Teradata Studio Express User Guide, Release 15.12 Chapter 5: Table Data Development Large Data and Objects Editing • Filename - For data objects over 64k, name of file that contains the data. You can edit or insert data in this file. BLOB data larger than 64k cannot be edited in the Blob Editor. To open the Blob Editor: 1. Select a table that contains a BLOB object and open it in the Table Data Editor. See Opening the Table Data Editor. The table name displays in the tab at the top of the editor. You can open several tables in the editor and move between them by clicking these tabs. 2. Select the BLOB to edit from the Binary Large Objects column. Single objects are separated in rows. 3. Click the ellipses ( ) at the right end of the row to open the Blob Editor. See About the Blob Editor. Editing BLOB Data You can edit a Binary Large Object (BLOB) by inserting, deleting, and changing the binary data contained in the object. 1. 2. 3. 4. Select a BLOB table in your database. Right-click the table and select Teradata > Edit Data. The table objects display in the Binary Large Object column in the Table Data Editor. Locate the BLOB you want to edit and select it. The table row highlights, and an ellipses ( ) displays at the right end of the row. 5. Click the ellipses ( ) to open the Blob Editor. 6. Review and edit the data in the object. 7. Click OK to save your changes to the object. Also you can export the data to a binary data file to review and edit the data, and then import that data back to the Blob Editor. About the Clob Editor You can use the Table Data Editor to review and edit database tables that contain Character Large Objects (CLOBs). A CLOB is a collection of character data stored as a single entity in a Database Management System (DBMS). Teradata Studio Express User Guide, Release 15.12 99 Chapter 5: Table Data Development Large Data and Objects Editing Source of Imported Data If the data in the object is imported, the source file for that data displays in the File field. Actions on Object You can import, export, or clear the binary data in CLOBs. These functions are selected by clicking the action buttons to the left of the Edit workarea. Editor Workarea The editor workarea displays the current data in the selected object for edit. You can insert, delete, and modify data displayed in this area. You can import from or export to files, such as a Microsoft Word file or text file. You can also remove all data by clicking Clear. Note: CLOB data larger than 64k can be viewed, exported, and imported, but not edited in the Clob Editor. To edit files larger than 64k, export to a text editor. Slidebars 100 Teradata Studio Express User Guide, Release 15.12 Chapter 5: Table Data Development Large Data and Objects Editing The data in an object is often more than can be displayed within the editing area. Use the slidebars on each side of the Edit workarea to scroll through data. Encoding Standard The Encoding fields shows the encoding standard used for the data in the editor workarea. Use the drop-down menu to select a different standard. Clob Editor The Clob Editor displays the character data contained in the selected Character Large Object (CLOB) stored in a database. You can edit the data in the CLOB by: • • • • • Inserting character data Deleting character data Clearing the character data in the object Importing character data from a file Exporting the character data in the object A CLOB data object can be represented in one of three ways: • CLOB handle - Handle to the CLOB data in the database. • Snippet of data - Text snippet you edit or insert in cell. • Filename - For data objects over 64k, name of file that contains the data. You can edit or insert data in this file. CLOB data larger than 64k cannot be edited in the Clob Editor. Edit Clob Value Use the Clob Editor to modify the character data in the Character Large Object (CLOB) that you selected from a CLOB table. Option Description File If data is imported, shows the name of the import source file. Editor Workarea Displays the character data in the selected object. Actions Use the action buttons to the right of the editor to import, export, or clear character data. Option Description Import Click to import character data from a file. Export Click to export the character data displayed in the editor to a file, such as a Microsoft Word or text file. Clear Click to remove all data displayed in the editor workarea. OK Click to save the data to the object. Opening the Clob Editor You open the Clob Editor from the Table Data Editor by selecting the row that contains the Character Large Object (CLOB) in the table. A CLOB data object can be represented in one of three ways: Teradata Studio Express User Guide, Release 15.12 101 Chapter 5: Table Data Development Large Data and Objects Editing • CLOB handle - Handle to the CLOB data in the database. • Snippet of data - Text snippet you edit or insert in cell. • Filename - For data objects over 64k, name of file that contains the data. You can edit or insert data in this file. CLOB data larger than 64k cannot be edited in the Clob Editor. To open the Clob Editor 1. Open a table that contains a CLOB object to edit in the Table Data Editor. The table name displays in the tab at the top of the editor. You can open several tables in the editor and move between them by clicking these tabs. See Opening the Table Data Editor for more information. 2. Select the CLOB to edit from the Character Large Objects column. Single objects are separated by rows. 3. Click the ellipses ( ) at the right end of the row to open the Clob Editor. See About the Clob Editor. Editing CLOB Data You can edit a Character Large Object (CLOB) by inserting, deleting, and changing the character data contained in the object. 1. 2. 3. 4. Select a CLOB table in your database. Right-click the table and select Teradata > Edit Data.. The table objects display in the Character Large Object column in the Table Data Editor. Locate the CLOB you want to edit and select it. The table row highlights, and an ellipses ( ) displays at the right end of the row. 5. Click the ellipses ( ) to open the Clob Editor. 6. Review and edit the data in the object. 7. Click OK to save your changes to the object. Also you can export the data to a Microsoft Word or text file to review and edit the data, and then import that data back to the Clob Editor. About the Large Binary Editor You open the Large Binary Editor from the Table Data Editor by selecting the row that contains large binary data in a table. The Large Binary Editor provides a large workarea where you can review and modify data, and export and import data. 102 Teradata Studio Express User Guide, Release 15.12 Chapter 5: Table Data Development Large Data and Objects Editing Actions on Object You can import, export, or clear the binary data in the editor. These functions are selected by clicking the action buttons to the left of the editor workarea. Editor Workarea The editor workarea displays the data you selected for edit. You can insert, delete, and modify data displayed in this area. You can import from or export to files, such as a Microsoft Excel file. You can also remove all data by clicking Clear. Slidebars Large binary data is frequently too large to display without scrolling the editing area. Use the slidebars on each side of the editor workarea to scroll right-left or up-down through data. Opening the Large Binary Editor You open the Large Binary Editor from the Table Data Editor by selecting the row that contains large binary data. 1. Open a table that contains rows of large binary data to edit in the Table Data Editor. The tab shows the name of the large binary data table you opened in the Table Data Editor. You can open several tables in the editor and move between them by clicking these tabs. See Opening the Table Data Editor for more information. Teradata Studio Express User Guide, Release 15.12 103 Chapter 5: Table Data Development Large Data and Objects Editing 2. Select a row to edit from the VARBYTE column by clicking the row. Data is stored as single objects in separate rows. 3. Click the ellipses ( ) at the right end of the row to open the Large Binary Editor. See About the Large Binary Editor. Large Binary Editor The Large Binary Editor displays the binary data you selected from a table you are editing in Table Data Editor. You can edit the data by: • • • • • Inserting binary data Deleting binary data Clearing the binary data in the editor Importing binary data from a file Exporting the binary data to a file Edit Binary Data Use the Large Binary Editor to modify the binary data in a table. The editor provides a large workarea that displays the binary data you selected from the table. Edit your binary data in this workarea. Actions Use the action buttons to the right of the editor to import, export, or clear binary data. Option Description Import Click to import binary data from a file. Export Click to export the binary data displayed in the editor to a file, such as a text file. Clear Click to remove all data displayed in the editor workarea. Table continued on next page. 104 Teradata Studio Express User Guide, Release 15.12 Chapter 5: Table Data Development Large Data and Objects Editing Option Description OK Click to save the data. Editing Large Binary Data You can use the Table Data Editor to display and edit tables that contain large binary data. A large binary data table contains raw binary data stored as VARBYTE data type. 1. 2. 3. 4. Select a table that contains large rows of raw binary data (VARBYTE) in your database. Right-click the table and select Teradata > Edit Data.. The table data displays in the VARBYTE column in the Table Data Editor. Locate the row you want to edit and select it. The table row highlights, and an ellipses ( ) displays at the right end of the row. 5. Click the ellipses ( ) to open the Large Text Editor. 6. Review and edit the data displayed in the editor. You can edit directly in the editor or you can export the data to a Microsoft Excel or text file to review and edit the data, and then import that data back to the Large Text Editor. 7. Click OK to save your changes to the object. About the Large Text Editor You can use the Table Data Editor to display and edit tables that contain character data. A large text data table contains large amounts of character data stored as VARCHAR data type and must be edited in the Large Text Editor. Teradata Studio Express User Guide, Release 15.12 105 Chapter 5: Table Data Development Large Data and Objects Editing Actions on All Data in Editor You can import, export, or clear the data displayed. These functions are selected by clicking the action buttons to the left of the editor workarea. Editor Workarea The editor workarea displays the large text data you selected to edit. You can insert, delete, and modify data displayed in this area. You can import from or export to files, such as a Microsoft Word file. You can also remove all data by clicking Clear. Slidebars The data in an object is often more than can be displayed within the editing area. Use the slidebars on each side of the Edit workarea to scroll through data. Encoding Standard The Encoding fields shows you the encoding standard used for the the data in the editor workarea. Use the drop-down menu to select a different standard. 106 Teradata Studio Express User Guide, Release 15.12 Chapter 5: Table Data Development Large Data and Objects Editing Large Text Editor The Large Text Editor enables you to edit VARCHAR or CHAR data stored in a large text data table. You can edit the data by: • • • • • Inserting character data Deleting character data Clearing the character data in the editor Importing character data from a file Exporting the character data to a file Edit Text Value Use the Large Text Editor to modify the character data in a table. The data you select displays in the workarea in the center of the editor. You can also export the data to a file where you can review and edit the data, then import it back into the editor. Actions Use the action buttons to the right of the editor to import, export, or clear character data. Option Description Import Click to import character data from a file. Export Click to export the character data displayed in the editor to a file, such as a Microsoft Word or text file. Clear Click to remove all data displayed in the editor workarea. OK Click to save the data to the object. Opening the Large Text Editor You open the Large Text Editor from the Table Data Editor by selecting the row that contains large text (VARCHAR) data. 1. Select a table that contains rows of large text data and open it in the Table Data Editor. See Opening the Table Data Editor. The name of the large text data table displays in the tab at the top of the Table Data Editor. You can open several tables in the editor and move between them by clicking these tabs. 2. Locate the data you want to edit in the VARCHAR column and click the row that contains the data. Data is stored as single objects in separate rows. 3. Click the ellipses ( ) at the right end of the row to open the Large Text Editor. See About the Large Text Editor. The data you selected displays in the Large Text Editor. Teradata Studio Express User Guide, Release 15.12 107 Chapter 5: Table Data Development Large Data and Objects Editing Editing Large Text Data You can use the Table Data Editor to display and edit tables that contain character data. A large text data table contains large amounts of character data stored as VARCHAR data type. The Table Data Editor provides a special Large Text Editor for this type of data. 1. Select a table that contains large rows of character data (VARCHAR) in your database. Data is stored as single objects in separate rows. 2. Right-click the table and select Teradata > Edit Data. You can open several tables in the editor in this way and move between them by clicking the tabs at the top of the editor. 3. The large text data displays in the VARCHAR column in the Table Data Editor. 4. Locate the row you want to edit and select it. The table row highlights, and an ellipses ( ) displays at the right end of the row. 5. Click the ellipses ( ) to open the Large Text Editor. 6. Review and edit the data displayed in the editor. You can edit directly in the editor or you can export the VARCHAR or CHAR data to a Microsoft Word or text file to review and edit the data, and then import that data back to the Large Text Editor. 7. Click OK to save your changes to the object. About the XML Data Type Editor You can use the Table Data Editor to access Extensible Markup Language (XML) data type objects stored in the connected database. To edit the data, you must edit the XML data type object in the XML Editor. 108 Teradata Studio Express User Guide, Release 15.12 Chapter 5: Table Data Development Large Data and Objects Editing Source of Imported Data If the data in the object is imported, the source file for that data displays in the File field. Actions on Object You can import, export, or clear the data in XML data type objects. These functions are selected by clicking the action buttons to the left of the Edit workarea. Editor Workarea The editor workarea displays the current data in the selected object for edit. You can insert, delete, and modify data displayed in this area. You can import from or export to files, such as a text file. You can also remove all data by clicking Clear. Slidebars The data in an object is often more than can be displayed within the editing area. Use the slidebars on each side of the workarea to scroll through data. Teradata Studio Express User Guide, Release 15.12 109 Chapter 5: Table Data Development Large Data and Objects Editing Encoding Standard The Encoding field shows the encoding standard used for the data in the editor workarea. Use the dropdown menu to select a different standard. XML Editor The XML Editor displays the Extensible Markup Language (XML) data contained in the selected XML data type object stored in a database. An XML data type object is represented by the handle to the XML data stored in the database. You can edit the data in the XML object by: • • • • Inserting XML data Clearing the XML data in the object Importing XML data from a file Exporting the XML data in the object to a file Edit XML Use the XML Editor to review and modify data in an XML data type object. that you selected using the Table Data Editor. Option Description File If data is imported, shows the name of the import source file. Editor Workarea Displays the data in the selected XML data type object. Actions Use the action buttons to the right of the editor to import, export, or clear XML data. Option Description Import Click to import XML data from a file. Export Click to export the XML data displayed in the editor to a file, such as a text file. Clear Click to remove all data displayed in the editor workarea. OK Click to save your data changes to the object. Opening the XML Editor You open the XML Editor from the Table Data Editor by selecting an XML data type object stored in a database table. An XML data type object is represented by the handle to the XML data in the database. 1. In the Table Data Editor, open a table that contains the XML data type object you want to edit. The table name displays in the tab at the top of the editor. You can open several tables in the editor and move between them by clicking these tabs. See Opening the Table Data Editor for more information. 2. Select the XML data type object to edit from the XML column. Single objects are separated by rows. 3. Click the ellipses ( ) at the right end of the row to open the XML Editor. See About the XML Editor. 110 Teradata Studio Express User Guide, Release 15.12 Chapter 5: Table Data Development Table Data Filtering Editing XML Data You can use the Table Data Editor to display and edit database tables that contain XML data types. The Table Data Editor provides a special XML Editor for this type of data. 1. Select a table in your database that contains the XML data type. XML data type objects are stored as single objects in separate rows within the table. 2. Right-click the table and select Teradata > Edit Data. You can open several tables in the editor in this way and move between them by clicking the tabs at the top of the editor. 3. Review the table. Any XML data displays in the XML column of the table and is visible in the Table Data Editor. 4. Locate the object you want to edit and select the row for that object. An XML data type object is represented by the handle to the stored XML data. When you select the object, the row highlights, and an ellipses ( ) displays at the right end of the row. 5. Click the ellipses ( ) to open the XML Editor. 6. Review and edit the data displayed in the editor. You can edit directly in the editor or you can export the XML data to a text file to review and edit the data, and then import that data back to the XML Editor. 7. In Encoding, select the encoding standard to use from the list. 8. Click OK to save your changes. Table Data Filtering About Filtering Table Data The Table Data Editor provides several ways to filter table data. You can filter data: • To view only data of interest in columns. See Displaying Column Data by Value. • To view only rows in which you have inserted, updated, or deleted data. See Selecting to Filter by Edits. Teradata Studio Express User Guide, Release 15.12 111 Chapter 5: Table Data Development Table Data Filtering • To view data of interest using Data Filter rules. See Filtering with Data Filter. About the Data Filter The Data Filter dialog enables you to set filter rules to define which data is loaded and displayed in the Table Data Editor. Each time you use this dialog, the data is reloaded into the editor based on the rules you specify. To access the Data Filter dialog, click the Filter icon in the Table Data Editor toolbar. The dialog consists of two tabs described below. Filter Tab The Filter tab lists all columns in the table and enables you to set filter rules for each column. It is comprised of the following elements: List of Columns in Table The Filter list displays all table columns. Select filter options in Select By to view in the Table Data Editor only data in which you are interested. 112 Teradata Studio Express User Guide, Release 15.12 Chapter 5: Table Data Development Table Data Filtering Data Type of Column The Types list shows the column data type. Selection of Filter Rule In Select By, create a filter rule to apply to the column. Use the list to select a filter operator and enter a value. For example, you could specify a rule that filters column data for only values greater than 1000. Filter operators are based on column data type. Filter Rules by Column The Data Filter dialog provides the ability to define specific filter rules for each column in the selected table. Use this area to define, review, and refine your Table Data Editor view for specific tables. The default is None. Clear All Button Click Clear All to reset filter rules for all columns to None. Sort Tab Use the Sort tab to specify column row order for the Sort operation. For example, if you move Column3 to the Sort Columns list and position it as the first column in the list, the Sort operation sorts all column rows based on the row order in Column3. The tab consists of the following elements: Teradata Studio Express User Guide, Release 15.12 113 Chapter 5: Table Data Development Table Data Filtering List of All Columns in Table A list of all table columns displays in the Table Columns selection box. You can order the list in either ascending or descending order by table name. Ordered List of Columns for Sort Move columns from Table Columns to Sort Columns to specify the column sort order. Use Up and Down to change column order. Choice Buttons: Order Table Column List Choose how you want the column list ordered: 114 Teradata Studio Express User Guide, Release 15.12 Chapter 5: Table Data Development Exporting Table Data • Ascending - Orders the Table Columns list from the smallest or lowest to the largest or higher value. For example, A to Z or 1 to 100. This is the default. • Descending - Orders the Table Columns list from the largest or higher value to the smallest or lowest value. For example, Z to A or 100 to 1. Action Buttons: Order Columns for Sorting Move columns up or down in the list. The sort operation uses the column order to determine sorting rules. The primary sort is based on the first column in the list. Exporting Table Data You can export data to a file, such as a Microsoft Excel spreadsheet or a text file. The Table Data Editor uses the Export Data Wizard to export data from tables. You can select data to export all data in the table or only data in specific rows to export. Exporting All Data The Export All feature exports all data in the table. 1. In the toolbar, click Export All. 2. Follow steps for Export Data Wizard below. Exporting Data in Rows The Export feature exports only data in the table rows you select. 1. 2. 3. 4. Select the data rows you want to export. You can select multiple rows using the Ctrl key. for export. Right-click and select Select Rows for Export. The rows are marked Right-click and select Export Selected Rows. Follow steps for the Export Data Wizard below. Exporting with Teradata Export Wizard 1. The Export Data dialog opens. Follow these steps for both Export All and Export tasks. 2. In Output File, type the path name of the file to which you want the data exported. You can also click Browse to locate and save the file. 3. In File Type, select from the list the type of the output file in the previous step. For example, you can select a delimited text file, Excel, or Excel (97-2003) file. 4. Select Column Labels in First Row to specify that you want column labels to be output in the first row of the file. 5. Under File Options, if you selected a delimited text file as the output, complete the following: a. In Column Delimiter, select the column delimiter to be used in the output file to separate columns. b. In Character String Delimiter, select the character string delimiter to be used in the output file to indicate character strings. 6. In File Encoding, select the encoding standard to use. 7. Click Finish to export the data. Teradata Studio Express User Guide, Release 15.12 115 Chapter 5: Table Data Development Exporting Table Data 116 Teradata Studio Express User Guide, Release 15.12 CHAPTER 6 Data Import and Export Importing Data Into a Volatile Table Prerequisite Volatile tables must be created manually, by executing CREATE VOLATILE TABLE statements from the SQL Editor. Volatile tables exist only during the session in which they are created. When a database session ends, Teradata Database automatically drops all volatile tables that were created during the session. After you have created a volatile table, use the Load Data wizard to import external data into the table. 1. In the SQL Editor view, click . The Load Data to Volatile Table dialog opens. 2. From the Volatile Table list, select the volatile table to which you want to import data, and click OK. Importing data to volatile tables is the purview of the Data Transfer perspective. The Switch Perspective dialog box may appear and offer to switch you to that perspective during this process. Switching perspectives is optional. The Data Transfer perspective shows the progress of the data import in the Progress Monitor view, and includes the Transfer History view, which may be helpful. After switching perspectives or dismissing the Switch Perspective dialog, the Data Transfer Wizard opens. 3. In the Data Transfer Wizard, for Source Type chose External File (Fastload), and click Launch. The Load Data Wizard opens. 4. For File Type specify the format of the file that has the external data. 5. For Input File, enter the name of the file, or click Browse to navigate to the file on your system or network. A sample of the data in the file is displayed in a tabular form preview of how the data will import to the table. If the sample data is not laying out correctly, use the controls in the wizard to specify how the data is formatted in the external file, and how you want the data to be parsed as it is imported to the database. 6. Click Finish. The external data is imported to the volatile table. Teradata Studio Express User Guide, Release 15.12 117 Chapter 6: Data Import and Export Import and Load External Data (Teradata, Aster) Import and Load External Data (Teradata, Aster) About the Load Data Wizard (Teradata, Aster) Once you have selected the table to receive the data in the Data Source Explorer, You can specify the type of data import you want performed. Note: You must select External File (FastLoad) as the Source Type to launch the Load Data Wizard. After the Load Data Wizard opens, specify the name, path, and external file type of the source file. Be sure to specify data delimiters and encoding used in the source file. Use the drop-down lists to select the correct information. 118 Teradata Studio Express User Guide, Release 15.12 Chapter 6: Data Import and Export Import and Load External Data (Teradata, Aster) Load Data Wizard (Teradata, Aster) The Load Data Wizard enables you to load data from an input file into a table using either JDBC FastLoad or batch operations. The input file can be a delimited text file or an Excel file. If the table is not empty, the Load Data Wizard appends or replaces the existing data. Note: JDBC FastLoad operations are not applicable to Aster data transfers. The Load Data Wizard contains the following elements: Teradata Studio Express User Guide, Release 15.12 119 Chapter 6: Data Import and Export Import and Load External Data (Teradata, Aster) Option Description Input File Specify the path and name of the file from which to import data and to specify the server path to its location in the file system. To locate an existing file, click Browse and navigate the file system to select a file. File Type Select the type of file to be imported. You can choose to load data from a text file, such as a.txt or.cvs file, or from a Microsoft Excel file. Choose between a.xslx file, or.xls (Microsoft Excel 97-2003) file. The file data options change depending on which type of source file you selected. Column Labels in First Row Select to specify that the first row in the file contains the column labels so that the first row in the file is ignored. Stop Loading If Max Error(s) Occur Specify the maximum number of errors allowed before the wizard stops the Load operation. Lock Table Select to prevent row lock errors. Note: Selecting this option may cause the import operation to be slow. Replace Existing Data If the table is not empty, check this option to replace the existing data. Leaving it cleared appends the loaded data to the existing data. If the table is empty, this option is grayed out. The File Options change depending on the file type you select, and the destination. For example, the Delimited Text options are: Option Description Column Delimiter Specify the column delimiter used in the input file. This does not apply to Hadoop. Character String Delimiter Specify the character string delimiter used in the input file. This does not apply to Hadoop. Line Separator Specify the type of column delimiters, character string delimiters, and character encoding the data in the imported file uses. If you specified an EXCEL spreadsheet as the input file and selected either EXCEL (.xlsx) or EXCEL 97-2003 (.xls) as the file type, you can import data from a single worksheet in the file by selecting a worksheet name in Import Worksheet. The Line Separator options enable you to import files that have only LineFeed (LF), as in Unix and Linux, or only Carriage Return (CR) as in Mac OS/X prior to v10.0, or both, as for Windows. The options are: • • • Windows OS (CR and LF) Prior to Mac OS X v10.0 (CR) Unix, Linux, Mac OS X v10.0 and above (LF) File Encoding Specify the type of encoding to used for the file. Start Loading at Row Number Specify the table row number where the Load operation begins. The Excel options are: 120 Teradata Studio Express User Guide, Release 15.12 Chapter 6: Data Import and Export Import and Load External Data (Teradata, Aster) Option Description Import Worksheet Import Worksheet - View a list of worksheets found in the specified Excel file. Specify which worksheet you want to import. Start Loading at Row Number Specify the table row number where the Load operation begins. Data contained in the external file displays at the bottom of the wizard screen. Table data includes column name, column data type, and values in table rows. When you click Finish, the results display in the Teradata SQL History view. Click the Message tab to view detailed messages. Loading Table Data from a File (Teradata, Aster) 1. 2. 3. 4. 5. 6. 7. Open the Data Transfer perspective. Select a Teradata or Aster table in the Data Source Explorer as the destination table. Right-click the table and select Data > Load Data. In the Data Transfer Wizard, select External File as the Source Type. Click Launch. The Load Data Wizard opens. At Input File, type the directory path and name of the file that contains the data you want to import. To find a file in your file system, click Browse, select the file, and click Open. In File Type, select one of the following options: Option Description Delimited Text Text file that uses delimiters to separate data; such as, commas or semicolons in a TXT or CSV file. Excel (.xlsx) Microsoft Excel file with.xlsx file extension. This is not available for Hadoop. Excel 87-2003 (.xls) Microsoft Excel file with.xls file extension. This is not available for Hadoop. 8. [Optional] Select Column Labels in First Row to use the first row of data as the column labels for the new table. 9. Select Stop Loading If Max Error(s) Occur and specify the maximum number of errors allowed before the Load operation stops. 10. [Optional] Select Lock Table to lock the source and destination tables during the Load operation. 11. [Optional] Select Replace Existing Data to specify that data in the source file replaces any existing data in the destination file. 12. Complete the File Options. For example, if you selected Delimited Text, complete the following fields: a) In Column Delimiter, select the delimiter that you want used to separate data. • • • • • Comma — Uses commas (,) to separate data in destination file Semicolon — Uses semicolons (;) to separate data in destination file Space — Uses blank spaces to separate data in destination file Tab — Uses Tabs to separate data in destination file Fixed Width — Uses fixed width columns to separate data. Specify in Fixed Width Columns a numeric value for the fixed column width. • I — Inserts a vertical bar (I) to separate data Teradata Studio Express User Guide, Release 15.12 121 Chapter 6: Data Import and Export Import and Load External Data (Hadoop) b) Select the Character String Delimiter to use to distinguish string text. The options are " (double-quotes), ' (single quote), or None. c) In Line Separator, select one of the following options based on the operating system from which the data is imported. This option enables you to import files with only Carriage Returns (CR), only LineFeeds (LF), or both Carriage Returns and LineFeeds (CR and LF). • Windows OS (CR and LF) • Prior to Mac OS X v10.0 (CR) • Unix, Linux, Mac OS X v10.0 and above (LF) d) In File Encoding, select the character set to use to encode the data. The options are: UTF-8, utf-16, ISO-8859-1, UTF-16BE, UTF-16LE, US-ASCB, Cp1252. e) In Start Loading At Row Number, type the table row number at which you want the wizard to start loading data. This option does not apply to Hadoop. A sample of the input file based on the options you select displays below the File Options. If you change the values selected in File Options fields, the sample row display also changes. 13. Click Finish. The wizard returns you to the Transfer History View where you can view the report on the Load operation success or failure. About the Load Data Wizard and JDBC The JDBC Driver returns SQL warnings if it determines that a FastLoad operation is not possible. This might be due to incompatible column data types; for example, CLOB or BLOB data types. If this occurs, the JDBC Driver processes the batch insert in a non-FastLoad mode. Note: The JDBC Driver feature is not applicable for Aster data transfers. When loading data, not all data type conversions supported by the Teradata JDBC Driver are supported by JDBC FastLoad or JDBC addBatch. This is an issue related to Date, Time, and Timestamp data types. Teradata recommends that when you load data for these data types, use the following JDBC escape formats: • JDBC Date escape format is: yyyy-mm-dd. • JDBC Time escape format is: hh:mm:ss. • JDBC Timestamp escape format is: yyyy-mm-dd hh:mm:ss.ffffff. Import and Load External Data (Hadoop) About the Load Data Wizard (Hadoop) Once you have selected the table to receive the data in the Data Source Explorer, You can specify the type of data import you want performed. Note: You must select External File as the Source Type to launch the Load Data Wizard. 122 Teradata Studio Express User Guide, Release 15.12 Chapter 6: Data Import and Export Import and Load External Data (Hadoop) After the Load Data Wizard opens, specify the name, path, and external file type of the source file. Use the drop-down lists to select the correct information. Load Data Wizard (Hadoop) The Load Data Wizard enables you to load data from an input file into a table using a combination of WebHDFS and JDBC. The input file must be a delimited text file. If the table is not empty, the Load Data Wizard appends or replaces the existing data. The Load Data Wizard for Hadoop contains the following elements: Option Description Input File Specify the path and name of the file from which to import data and to specify the server path to its location in the file system. To locate an existing file, click Browse and navigate the file system to select a file. Table continued on next page. Teradata Studio Express User Guide, Release 15.12 123 Chapter 6: Data Import and Export Import and Load External Data (Hadoop) Option Description File Type File type is Delimited Text. This cannot be changed. Delimiter The delimiter corresponds to the delimiter of the Hadoop table you are importing. Table File Format The table file format corresponds to the table file format of the Hadoop table you are importing. Replace Existing Data If the table is not empty, check this option to replace the existing data. Leaving it cleared appends the loaded data to the existing data. If the table is empty, this option is grayed out. Line Separator Specify the line separator used in the file you are importing. . File Encoding Specify the type of encoding to used for the file. Data contained in the external file displays at the bottom of the wizard screen. Table data includes column name, column data type, and values in table rows. When you click Finish, a file transfer job is launched in the Transfer Progress View view. When the transfer is complete, it is displayed in the Transfer History View. Loading Table Data from a File (Hadoop) 1. 2. 3. 4. 5. 6. 7. 8. Open the Data Transfer perspective. Select a Hadoop table in the Data Source Explorer as the destination table. Right-click the table and select Data > Load Data. In the Data Transfer Wizard, select External File as the Source Type. Click Launch. The Load Data Wizard opens. At Input File, type the directory path and name of the file that contains the data you want to import. To find a file in your file system, click Browse, select the file, and click Open. [Optional] Select Replace Existing Data to specify that data in the source file replaces any existing data in the destination file. In Line Separator, select one of the following options based on the operating system from which the data is imported. This option enables you to import files with only Carriage Returns (CR), only LineFeeds (LF), or both Carriage Returns and LineFeeds (CR and LF). • Windows OS (CR and LF) • Prior to Mac OS X v10.0 (CR) • Unix, Linux, Mac OS X v10.0 and above (LF) 9. In File Encoding, select the character set to use to encode the data. The options are: UTF-8, UTF-16, ISO-8859-1, UTF-16BE, UTF-16LE, US-ASCB, Cp1252. A sample of the input file based on the options you select displays below the File Options. If you change the values selected in File Options fields, the sample row display also changes. 10. Click Finish. When you click Finish, a file transfer job is launched in the Transfer Progress View view. When the transfer is complete, it is displayed in the Transfer History View. 124 Teradata Studio Express User Guide, Release 15.12 Chapter 6: Data Import and Export About Smart Load Wizard (Teradata, Aster) About Smart Load Wizard (Teradata, Aster) The Smart Load Wizard enables you to create Teradata or Aster tables from data stored in an external file. This screen varies with destination system and options selected. Import File Enter the path and name for the file to import or click Browse to find a file on your file system. File Type Select the type of file to import. The default file type is delimited text. The Microsoft Excel file type has options for files with .xlsx and .xls extensions. Column Labels in First Row Select to specify that the first row in the file contains the column labels so that the first row in the file is ignored. Teradata Studio Express User Guide, Release 15.12 125 Chapter 6: Data Import and Export About Smart Load Wizard (Teradata, Aster) Quick Scan Select to scan the file partially when trying to derive a table from the imported data. Column Delimiter Specify the column delimiter used in the input file. Character String Delimiter Specify the character string delimiter used in the input file. Line Separator Specify the type of column delimiters, character string delimiters, and character encoding the data in the imported file uses. If you specified an EXCEL spreadsheet as the input file and selected either EXCEL (.xlsx) or EXCEL 97-2003 (.xls) as the file type, you can import data from a single worksheet in the file by selecting a worksheet name in Import Worksheet. The Line Separator options enable you to import files that have only LineFeed (LF), as in Unix and Linux, or only Carriage Return (CR) as in Mac OS/X prior to v10.0, or both, as for Windows. The options are: • Windows OS (CR and LF) • Prior to Mac OS X v10.0 (CR) • Unix, Linux, Mac OS X v10.0 and above (LF) File Encoding Specify the type of encoding to used for the file. Creating Tables with Smart Load (Teradata, Aster) Use this procedure to create a new Teradata or Aster table by importing data from an external file. 1. 2. 3. 4. 5. 6. 126 In Data Source Explorer right-click Tables on a Teradata or Aster system. Choose the correct option for your system: Option Action Teradata Teradata > Data Transfer Aster Aster > Data Transfer The Data Transfer Wizard displays. In Source Type, select External File (Smart Load). Click Launch. The Smart Load Wizard opens. In Input File, type the directory path and name of the file that contains data you want to use to build a table. You can also browse to the file. Select the File Type for the input file: Option Description Delimited Text Text file that uses delimiters to separate data; such as, commas or semicolons in a TXT or CSV file. Excel (.xlsx) Microsoft Excel file with .xlsx file extension. Teradata Studio Express User Guide, Release 15.12 Chapter 6: Data Import and Export About Smart Load Wizard (Teradata, Aster) Option Description Excel 87-2003 (.xls) Microsoft Excel file with .xls file extension. 7. [Optional] Select Column Labels in First Row to specify to use the first row of data as the column labels for the new table. 8. [Optional] In Drop Table if Max Error(s) Occur, type the maximum number of errors that a table can have before it is dropped from the import operation. 9. [Optional] If you selected Delimited Text, select Quick Scan to scan the file partially when trying to derive a table from the imported data. 10. If you selected Delimited Text, use the list in Column Delimiter to select the delimiter that is used to separate data in the input file. Option Description Comma Input file data is separated by commas (,) Semicolon Input file data is separated by semicolons (;) Space Input file data is separated by blank spaces Tab Input file data is separated by Tabs Fixed Width Input file data has fixed width columns. Specify in the Fixed Width Columns field a numeric value for the fixed column width. I Vertical bar (I) is used to separate data 11. If you selected Delimited Text, select the Character String Delimiter to use to distinguish string text. The options are " (double-quotes), ' (single quote), or None. This option does not apply to Hadoop. 12. If you selected Delimited Text, in Line Separator select one of the following options based on the operating system from which the data is imported. This option enables you to import files with only Carriage Returns (CR), only LineFeeds (LF), or both Carriage Returns and LineFeeds (CR and LF). 13. 14. 15. 16. 17. 18. 19. • Windows OS (CR and LF) • Prior to Mac OS X v10.0 (CR) • Unix, Linux, Mac OS X v10.0 and above (LF) If you selected Delimited Text, in File Encoding select the character set to use to encode the data. The options are: UTF-8, utf-16, ISO-8859-1, UTF-16BE, UTF-16LE, US-ASCB, Cp1252. Click Next. The Table Column Data Types screen displays. In Table Name, type the name of the table to be derived from the loaded data. [Teradata Only] In Primary Index, select whether this table will have a primary index, and whether it is unique. The Teradata primary index is used to evenly distribute data among AMPs.A non-unique primary index permits the insertion of duplicate field values. Select the Table Type. To edit the data types of a specific column, click (ellipses) in the column header. Select one of the following: Option Description Click Next Previews the SQL/DDL code that creates the new table. You can edit the SQL statements in the Generated SQL text area by clicking Show in Editor. If you choose to open the SQL Editor, the Teradata Studio Express User Guide, Release 15.12 127 Chapter 6: Data Import and Export About Smart Load Wizard (Teradata, Aster) Option Description Smart Load Wizard closes. You can run the SQL query statements from the SQL Editor to create the table. Click Finish Creates the table and imports the data from the file. Editing Column Data Types (Teradata, Aster) You can edit the data type for a table column prior to importing data in the Smart Load Wizard. The exact menu options vary depending on the table type and the column type. 1. On the Data Types page, click the ellipsis next to the data type to change. 2. In Type select the data type for the column you are editing. The remaining options vary depending on the data type. 3. Select Can contain nulls if the data in the column can include null values. This action de-selects Values must be unique if it is selected. 4. Select Values must be unique if the data in the column must be unique values. This action deselects Can contain nulls. 5. If you selected SMALLINT as the data type, you can select Distribute by Hash if you want specify a distribution key column. Using Distribute by Hash with a distribution key is mandatory for fact tables and optional for dimension tables. Joins involving columns that are part of a distribution key constraint will be optimized. 128 Teradata Studio Express User Guide, Release 15.12 Chapter 6: Data Import and Export About Smart Load Wizard (Teradata, Aster) 6. Click OK. Smart Load Data Types for Teradata Tables The following data types are supported in the Smart Load Wizard for Teradata tables. Teradata Data Type Description BYTE Fixed length binary string CHARACTER Fixed length character string. In Size type the size limit of the character string. CHARACTER LARGE OBJECT Large character string DATE A date consisting of year/month/day DECIMAL Decimal number with fixed number of digits and a fixed number of digits to the right of the decimal point DOUBLE PRECISION Floating-point data type. There are no additional options. FLOAT Floating point number INTEGER 32-bit binary integer. There are no additional options. INTERVAL There are no additional options. INTERVAL DAY An interval defining a period of time in days INTERVAL DAY TO HOUR An interval defining a period of time in days and hours INTERVAL DAY TO MINUTE An interval defining a period of time in days, hours and INTERVAL DAY TO SECOND An interval defining a period of time in days, hours, minutes and seconds INTERVAL HOUR An interval defining a period of time in hours INTERVAL HOUR TO MINUTE An interval defining a period of time in hours and minutes INTERVAL HOUR TO SECOND An interval defining a period of time in hours, minutes and seconds INTERVAL MINUTE An interval defining a period of time in minutes INTERVAL MINUTE TO SECOND An interval defining a period of time in minutes and seconds INTERVAL MONTH An interval defining a period of time in months INTERVAL SECOND An interval defining a period of time in seconds INTERVAL YEAR An interval defining a period of time in years INTERVAL YEAR TO MONTH An interval defining a period of time in years and months JSON (JavaScript Object Notation) text-based, data interchange format used in web applications to transmit data NUMERIC Numeric data such as integers, real numbers, and floating-point numbers. PERIOD(DATE) A period of dates consisting of year/month/day. (This type is available only for Teradata 13 and later.) PERIOD(TIME) A period of times consisting of hour/minute/second/fractional second. (This type is available only for Teradata 13 and later.) Table continued on next page. Teradata Studio Express User Guide, Release 15.12 129 Chapter 6: Data Import and Export About Smart Load Wizard (Teradata, Aster) Teradata Data Type Description PERIOD(TIME WITH TIME ZONE) A PERIOD(TIME) with displacements from UTC. (This type is available only for Teradata 13 and later.) PERIOD(TIMESTAMP) A period of timestamps consisting of year/month/day/hour/minute/second/ fractional second. (This type is available only for Teradata 13 and later.) REAL Floating-point data type. No additional options. SMALLINT 16-bit binary integer. There are no additional options to enter. TEXT In Size type the limit of the text size. TIME A time consisting of hour/minute/second/fractional second TIME WITH TIME ZONE A TIME with a displacement from UTC TIMESTAMP A timestamp consisting of year/month/day/hour/minute/second/fractional second TIMESTAMP WITH TIME ZONE A TIMESTAMP with a displacement from UTC VARBYTE Variable length binary string VARCHAR Variable length character string XML (eXtensible Markup Language) text-based, data format used for application integration to format messages passed between applications and as a document format for storing data Smart Load Data Types for Aster Tables The following data types are supported in the Smart Load Wizard for Aster tables. Aster Option Description BYTEA Variable-length binary string CHAR Fixed length character string. In Size type the size limit of the character string. DATE A calendar date consisting of year/month/day DOUBLE PRECISION Double-precision Floating-point number. There are no additional options. INTEGER 32-bit binary integer. There are no additional options. INTERVAL There are no additional options. IP4 IP address IP4Range Range of IP addresses NUMERIC Numeric data such as integers, real numbers, and floating-point numbers. An Aster Database numeric must have a scale and precision to be exported, due to the different meanings of precision and scale in different systems. In Precision, type the total count of significant digits in the whole number, that is, the number of digits to both sides of the decimal point. In Scale, type the count of decimal digits in the fractional part, to the right of the decimal point. For example, the number 23.5141 has a precision of 6 and a scale of 4. SMALLINT Signed two-byte integer. There are no additional options to enter. Table continued on next page. 130 Teradata Studio Express User Guide, Release 15.12 Chapter 6: Data Import and Export About Smart Load Wizard (Hadoop) Aster Option Description TEXT Stores strings of any length. In Size type the limit of the text size. TIME A time consisting of hour/minute/second/fractional second TIME WITH TIME ZONE A TIME with a displacement from UTC TIMESTAMP A timestamp consisting of year/month/day/hour/minute/second/fractional second TIMESTAMP WITH TIME ZONE A TIMESTAMP with a displacement from UTC UUID Stores Universally Unique Identifiers (UUID) as defined by RFC 4122, ISO/IEC 9834-8:2005, and related standards. VARBIT Variable length binary string VARCHAR Variable length character string About Smart Load Wizard (Hadoop) The Smart Load Wizard enables you to create Hadoop tables derived from data stored in an external file. Input File Teradata Studio Express User Guide, Release 15.12 131 Chapter 6: Data Import and Export About Smart Load Wizard (Hadoop) Enter the path and name for the file to import or click Browse to find a file on your file system. File Type This is Delimited Text for Hadoop destinations. Column Labels in First Row Select to specify that the first row in the file contains the column labels so that the first row in the file is ignored. This option is not available for Cloudera systems. Column Delimiter Specify the column delimiter used in the input file. Line Separator The Line Separator options enable you to import files that have only LineFeed (LF), as in Unix and Linux, or only Carriage Return (CR) as in Mac OS/X prior to v10.0, or both, as for Windows. The options are: • Windows OS (CR and LF) • Prior to Mac OS X v10.0 (CR) • Unix, Linux, Mac OS X v10.0 and above (LF) File Encoding Specify the type of encoding to used for the file. Creating Tables with Smart Load (Hadoop) Use this procedure to create a new Hadoop table by importing data from an external file. 1. 2. 3. 4. 5. 6. 7. 132 In Data Source Explorer right-click Tables on a Hadoop system. Select Hadoop > Data Transfer. The Data Transfer Wizard displays. In Source Type, select External File (Smart Load). Click Launch. The Smart Loader for Hadoop Wizard opens. In Input File, type the directory path and name of the file that contains data you want to use to build a table. You can also browse to the file. [Optional] Select Column Labels in First Row to specify to use the first row of data as the column labels for the new table. This option is not available for Cloudera systems. At Column Delimiter, select the delimiter that is used to separate data in the input file. Option Description Comma Input file data is separated by commas (,) Semicolon Input file data is separated by semicolons (;) Space Input file data is separated by blank spaces Tab Input file data is separated by Tabs Teradata Studio Express User Guide, Release 15.12 Chapter 6: Data Import and Export About Smart Load Wizard (Hadoop) 8. In Line Separator, select one of the following options based on the operating system from which the data is imported. This option enables you to import files with only Carriage Returns (CR), only LineFeeds (LF), or both Carriage Returns and LineFeeds (CR and LF). • Windows OS (CR and LF) • Prior to Mac OS X v10.0 (CR) • Unix, Linux, Mac OS X v10.0 and above (LF) 9. In File Encoding select the character set to use to encode the data. The options are: UTF-8, UTF-16, ISO-8859-1, UTF-16BE, UTF-16LE, US-ASCB, Cp1252. 10. Click Next. The Hadoop Table Properties screen displays. 11. In Table Name, type the name of the table to be derived from the loaded data. 12. In Table File Format, select the format of the data in the table. Supported table file format types are TEXT (default), SEQUENCE, RC, and ORC. ORC is only available for Hortonworks. For Cloudera Systems, if RC or SEQUENCE is selected for Table File Format, the wizard requires Hive JDBC Properties. Note: The hive host name field is prepopulated with the impala host name. If the hive host name is different, modify the field to the correct host value. 13. To edit the data types of a specific column, click (ellipses) in the column header. 14. Select one of the following: Option Description Click Next Previews the SQL/DDL code that creates the new table. You can edit the SQL statements in the Generated SQL text area by clicking Show in Editor. If you choose to open the SQL Editor, the Smart Load Wizard closes. You can run the SQL query statements from the SQL Editor to create the table. Click Finish Creates the table and imports the data from the file. Teradata Studio Express User Guide, Release 15.12 133 Chapter 6: Data Import and Export About Smart Load Wizard (Hadoop) Editing Column Data Types (Hadoop) You can edit the data type for a table column prior to importing data in the Smart Load Wizard. The exact menu options vary depending on the table type and the column type. 1. On the Data Types page, click the ellipsis next to the data type to change. 2. In Type select the data type for the column you are editing. 3. Click OK. Smart Load Data Types for Hadoop Tables The following data types are supported in the Smart Load Wizard for Hadoop tables. Teradata Data Type Description BIGINT 8-byte binary integer. There are no additional options. DATE A date consisting of year/month/day. This does not apply to Cloudera systems. DOUBLE Floating-point data type. There are no additional options. FLOAT Floating point number INT 32-bit binary integer. There are no additional options. SMALLINT 16-bit binary integer. There are no additional options. STRING Character string. TIMESTAMP A timestamp consisting of year/month/day/hour/minute/second/fractional second. Cloudera systems can also use year/month/day. TINYINT 134 8-bit binary integer. There are no additional options. Teradata Studio Express User Guide, Release 15.12 Chapter 6: Data Import and Export Export External Data Export External Data About the Export Data Wizard The Export Data Wizard enables you to export data from a table to a file in a file system. Export Data to External File In this section you can specify the name of the file to receive the data and the server path to its location in the file system. To locate an existing file, click Browse and navigate the file system to select a file. You can choose to export data to a text file, such as a .txt or .cvs file, or to a Microsoft Excel file. Choose between a .xslx file, or .xls (Microsoft Excel 97-2003) file. The file data options change depending on which type of output file you select. Table Column Option Selecting Select Column Labels in First Row retrieves the column headers in the table to be written as the column labels in the first row of data in the export file. Export File Delimiters and Encoding A delimiter is a character or sequence of characters that specify the boundaries of independent regions of data in plain text by distinguishing the beginning and end of the unit of data, such as a field value. You must select how you want to delimit data from exported table columns when it is imported to Teradata Studio Express User Guide, Release 15.12 135 Chapter 6: Data Import and Export Transfer Progress View the target file. You can accept the default to use commas or you can use choose to use semicolons, spaces, tabs, or vertical bars (|). You can optionally select delimiters for character strings and the type of file encoding to use. Controls Control buttons are used to move forward or backward within the Export Data Wizard. When you are ready to export data, click Finish. A Progress Information dialog displays to show the progress of the export task. Exporting Table Data to an External File You can select a database table in the Data Source Explorer and export the data in the table to a TXT, CSV, XSL, or XSLX file in your file system. When you select to export data to an external file, the Export Data Wizard opens and prompts you for information about the data transfer operation. 1. Select a table object in the Data Source Explorer to use as the source table for exporting data to a file. 2. Right-click the selected table object and select Data > Export Data. 3. In the Data Transfer Wizard, select External File (FastExport) as the Destination Type. The Export Data Wizard opens. Transfer Progress View About the Transfer Progress View The Transfer Progress View displays a list of executing data transfer jobs and their status. It provides information about the source and destination tables for the data transfer, name of the transfer job, and start time, as well as the current elapsed time for the transfer operation. A progress bar appears in the right-most column for each executing job and shows the current progress state of the transfer compared to the estimated length of time to completion. The Transfer Progress View runs a single job to completion before it starts the next job. If multiple jobs are submitted at the same time, the jobs are placed in a queue and run in sequence. If you close Teradata Studio while jobs are running or queued, the jobs are cancelled. Cancelled jobs are moved to the History View where you can re-execute the jobs at a later time. If you close the view and need to re-open it, go to Window > Window > Transfer Progress View. The Transfer Progress View automatically displays when you select the Data Transfer perspective. List of Transfer Jobs 136 Teradata Studio Express User Guide, Release 15.12 Chapter 6: Data Import and Export Transfer Progress View The view displays a list of the data transfer jobs that are currently executing. After a job completes, you can view the transfer report in the Transfer History View and re-execute the job if needed. Job Information The view provides the following details for each data transfer job. Menu Description Job Type Indicates the system type (Aster, Hadoop, or Teradata) and the type of transfer job; for example, whether the job is an Aster Load, Teradata Table Copy, Import from Hadoop to Teradata, or Export from Teradata to Hadoop. Name Displays the name which can be changed before the job begins in the setup wizard or after the job has completed in the Transfer History View. By default, the name of the job is the job type followed by the name of the table that is being transferred. Start Time Displays the time stamp for the start of the data transfer operation. Time Elapsed Displays how long the job has been running. The entry displays "CANCELING" if the transfer is in the process of being canceled. The elapsed time value is updated continuously until the transfer completes. Summary Displays the names of the source and destination tables for the transfer job. Progress When a transfer job is running, the Progress bar shows the percentage of completion by displaying a green bar that gradually expands in length as the job progresses. Progress Bar The view displays a list of the data transfer jobs that are currently executing. After a job completes, it becomes an entry in the Transfer History View . Queue List Transfer jobs run one at a time. If a job is already running, the next job request is placed in the queue and designated as "queued" in the Progress column. Toolbar The Transfer Progress View toolbar allows you to cancel any jobs that are running and to view additional details about a job in the view list. Icon Menu Description Cancel Cancels the selected job in progress. The cancelled job displays in the Transfer History View. Transfer Details Opens the Transfer Details dialog that displays the output from the transfer job while it is running. After the job completes, the output is available in the Transfer History View. Transfer Details The Transfer Details dialog displays the output of the transfer operation while the job is running. Teradata Studio Express User Guide, Release 15.12 137 Chapter 6: Data Import and Export Transfer History View After the job completes, you can view the output in the Transfer History View. Job Details The Job Details dialog displays the output of the transfer operation while the job is running. After the job completes, you can view the output in the Transfer History View. Transfer History View About the Transfer History View The Teradata Transfer History view provides an enhanced display of the Data Transfer History information in the database. As data transfers are performed, an entry is placed in the Transfer History. The Transfer History view displays the data in a grid format that enables you to select rows or cells. The Transfer History view provides extensive information about the data transfer event, such as the name, start time, rows transferred, source and destination systems, status (Completed, Canceled, or Failed), and summary. It provides options to: • • • • 138 Copy selected cells to the clipboard Sort columns Delete rows Edit "Note" or "Name" for a history entry Teradata Studio Express User Guide, Release 15.12 Chapter 6: Data Import and Export Transfer History View • • • • • Filter columns Search for transfer history data Hide and show columns Auto-resize columns or rows Display the job output for a History entry The Transfer History view uses an embedded Derby Database to manage the Transfer History entries. If you close the view, select Window > Show View > Transfer History View to reopen the view. You can add notes manually by selecting the Transfer History ViewNote entry and in the toolbar clicking Edit Note. In the Transfer History Note dialog, type the note you want added to the Transfer History View entry. All columns are sortable in ASC/DSC order with the exception of the parameters column. The columns are sorted by left clicking the mouse button. This is for single column sorting only. Columns are movable by selecting the column and dragging it to the new location. Columns are also resizable. Rows can be selected by clicking in the numbered row header. If a filter is in effect, the result of a newly executed data transfer is inserted at the top row, regardless of whether it meets the filter criterion. If a sort is in effect the new entry is inserted in the sorted order. The Summary column contains a brief summary of the data transfer, such as the source database and table names. The Job Output can be displayed by selecting the history entry and clicking Show Job Output in the toolbar. Failed data transfers display as red text in the Status column. Toolbar Actions Icon Option Description Edit name Click to edit the name of the transfer history entry. Edit note Click to edit the note field of the transfer history entry. Delete selected row(s) Click to delete selected row(s) from the view and transfer history database. Filter display Click to open a dialog to filter display. Clear filter Click to clears the filter and refresh the transfer history display. Show job output Click to show the job output. Toolbar Menu Icon Option Description Edit Name Click to edit the name of the transfer history entry. Edit Note Click to edit the note of the transfer history entry. Delete Selected Row(s) Click to delete selected row(s) from the view and transfer history database. Delete All Transfer History Click to delete all entries in the transfer history database. Table continued on next page. Teradata Studio Express User Guide, Release 15.12 139 Chapter 6: Data Import and Export Transfer History View Icon Option Description Filter Click to open a dialog to Filter display. Clear Filter Click to remove the current filter from the display. Reexcute Click to execute the selected data transfer job in the Transfer History list. Show Transfer Job Output Click to display the job output for the selected data transfer job. Column Headers Column Name Description Name Name of the transfer job. Timestamp Time of transfer event. Format is yyyy-mm-dd hh:mm:ss.mm. Source Profile name for database that was the data source for the transfer. Destination Profile name of the database to which the data was transferred. Status Status of the transfer event. Duration Length of time required to transfer data between the source and destination. The format is hh:mm:ss.mm. Rows Transferred Number of table rows transferred. Note Text notes about transfer event. Summary Technical summary describing transfer source and destination paths. Column Header Context Menu Right-click a column header to hide, show, and resize columns. You can also use the Find feature to locate data in column rows. Icon Option Description Hide column Hides the current column. Show all columns Shows all columns. Auto resize column Resizes the current column. Find Displays the Find dialog to search rows in the column for a value. - Searches the Transfer History View for a value. Transfer History Filter The Transfer History Filter dialog enables you to filter rows in the transfer history view. Only rows meeting the filter criterion are displayed. 140 Teradata Studio Express User Guide, Release 15.12 Chapter 6: Data Import and Export Transfer History View Note: New data transfers appear regardless of whether or not they meet the filter criterion. There are three types of filter criterion: • LIKE, where '_' matches a single character, '%' matches 0 or more characters, like using abc% to filter values that start with 'abc' • EQUALS (=), which is equals match • Less than, equal, greater than(<, =, >), which is a less than, equals, or greater than match • Selection, which is a list selection match. The dialog contains the following elements: Element Description Name Filters on the Name column. This is a "LIKE" filter. Timestamp Filters on the Date portion of the Timestamp column. There are two options. If "day's" is selected, the indicated number of days history is displayed. "1" indicates the current day, "2" indicates today and the day before. If the "day's" check box is cleared, choose the operation, "<, =, >" and choose the date. Source Filters on the Source column. This is a "LIKE" filter. Destination Filters on the Destination column. This is a "LIKE" filter. Status Filters on the Status column. Choose from the selection list Completed, Canceled, or Failed. Duration Filters on the Duration column. This is a less than, equal, greater than filter. Rows Transferred Filters on the Rows Transferred column. This is a less than, equal, greater than filter. Note Filters on the Note column. This is a "LIKE" filter. Summary Filters on the Summary column. This is a "LIKE" filter. Sort The Sort dialog enables you to perform multi-column sorting. Select columns from the Columns list and move them to the list of columns to be sorted. Use the sort direction to move columns from and to lists. If a subsequent single column sort is made by clicking a column header, the multi-column sort is removed. Teradata Studio Express User Guide, Release 15.12 141 Chapter 6: Data Import and Export Transfer History View 142 Teradata Studio Express User Guide, Release 15.12 CHAPTER 7 Troubleshooting Troubleshooting Teradata Error Log The Teradata error log, teradata.log, is located in the user workspace .metadata/Teradata directory. Log messages are sent to the teradata.log file as well as to the Teradata Log console. To display the Teradata Log console, first you need to open the Console View. From the main menu, select Window > Show Views > Other. Then select General > Console and click OK. The Console View opens at the bottom of the screen. From the Console View toolbar you can open the Teradata Log console by clicking the down arrow icon and selecting TeradataLog. Eclipse Error Log Eclipse provides an error log to display any Eclipse error messages. Display this view by selecting Window > Show View and selecting Error Log. Turning on Debug You can configure the level of logging desired via the Teradata Logging Preferences page. Logging levels for the Teradata Log console and the Teradata log file are controlled separately. For example, you can change the logging level for the Teradata log file by clicking the DEBUG button under the Datatools Logging Level, then clicking Apply. This action enables debug logging for all of Teradata Studio plug-ins, with log messages going to the teradata.log file. You can also add a Logger for more localized logging. For example, you can log debug messages for only the com.teradata.datatools.dtp.catalog plug-in. Here are the steps for turning on the debug logging level: 1. Click the Loggers New button. 2. Enter the name of the plug-in, such as com.teradata.datatools.dtp.catalog. 3. Select com.teradata.datatools.dtp.catalog in the Loggers list and choose the logging level, such as DEBUG. 4. Click Apply. Teradata Studio Express User Guide, Release 15.12 143 Chapter 7: Troubleshooting Troubleshooting This enables debug message logging for the com.teradata.datatools.dtp.catalog plug-in, with log messages going to the teradata.log file. You can add additional plug-ins to the list and configure each with its own logging level. Increasing Memory Settings (OutOfMemory Error) Memory settings used when launching Teradata Studio can be specified through the Java Virtual Machine arguments option (-vmargs). The TeradataStudio.ini file contains VM argument settings, such as Xms512m -Xmx512m -XX:MaxPermSize=512m (setting all three arguments to 512 megabytes). The VM argument settings are dependent on the amount of memory available in the system. On Windows, Linux, and Mac OS X systems, the TeradataStudio.ini file is located in the installation directory. 144 Teradata Studio Express User Guide, Release 15.12