SQL01 SQL Assistant
SQL01 SQL Assistant
ROW A record
COLUMN A field
EMPLOYEE
MGR
EMP EMP DEPT JOB LAST FIRST HIRE BIRTH SAL
NUM NUM NUM CODE NAME NAME DATE DATE AMT
PK FK FK FK
1006 1019 301 312101 Stein John 761015 531015 2945000
1008 1019 301 312102 Kanieski Carol 770201 580517 2925000
1005 0801 403 431100 Ryan Loretta 761015 550910 3120000
1004 1003 401 412101 Johnson Darlene 761015 460423 3630000
1007 1005 403 432101 Villegas Arnando 770102 370131 4970000
1003 0801 401 411100 Trader James 760731 470619 3785000
Teradata naming rules may be used as follows on all Teradata database objects:
Names are composed of the following characters:
A - Z (Upper or lowercase)
0-9
#, $, _
Names are limited to 30 characters.
Names may not begin with a numeric value.
Account_Table
Financials_2001_DB
Sales_$_Column
#_of_Years_Column
SQL Assistant
Is ODBC-compliant.
(Can be used to access any ODBC-compliant Database.)
Saves information about previous query result sets.
Permits retrieval of previously used queries.
Supports DDL, DML and DCL commands.
Supports ANSI or BTET transaction protocols.
May be used to import or export data.
(Not covered by this course.)
Allows many options for tuning how it works.
Logging On Through SQL Assistant
The sequence for logging on to a Teradata system varies depending on how SQL
Assistant is set up. In our example, a user name appears, requiring only a
password.
Connect
Plug
SQL Assistant is a
Windows based GUI to
Teradatas data dictionary.
- Right-clicking on areas
- Double-clicking on fields
- Clicking on drop-downs Explorer
- Click and drag from Tree
explorer tree to query Window Results Window
window.
Explorer Tree
Information on
Employee_Sales.
The HELP TABLE command returns information about a database or user object.
Qualifications for SQL are databasename.tablename.columnname
Explorer Tree
information on table
Employee.
SQL Request
Cursor on column
Last_Name shows
hidden information.
Result of HELP
TABLE command on
table Employee.
Other SQL HELP Commands
Database Objects:
HELP TABLE Employee;
HELP VIEW Emp_Views.emp;
For a complete list of
HELP MACRO payroll_3;
HELP objects, issue the
HELP COLUMN Employee_Sales.employee.last_name;
following:
HELP INDEX employee;
HELP STATISTICS employee;
HELP 'SQL HELP';
HELP CONSTRAINT employee.over_21;
HELP VOLATILE TABLE vol_tab1;
We will take a closer look
HELP JOIN INDEX Employee_Sales.Employee;
at this special syntax in a
HELP HASH INDEX Employee_Sales.Department;
later module.
HELP TRIGGER trigger1;
HELP PROCEDURE proc1;
HELP FUNCTION func1;
The 3 different levels for referencing objects are: Database, Table, and Column.
Setting a Default Database via SQL
Default database
is DLM.
Changes the After issuing the database default request shown, which
default database to database will be checked for the following?
Employee_Sales. HELP TABLE Employee;
Clicking on SQL
Statement in History
will recall it to the Query
Window later.
Setting a Default Database via SQL
Assistant
A default database can be assigned through SQL Assistant like this.
TOOLS
DEFINE ODBC DATA SOURCE
SYSTEM DSN
CONFIGURE
Right-Click
Show Definition
For a complete list of objects referenced by the SHOW command you can issue the
following:
One method for retrieving information about your current session is to reference the
session variables below. (These are sometimes referred to as Built-in Functions)
Another method for listing session information is to issue the request shown below.
Note that the scroll bar indicates more information is available for viewing.
Tools Options Query Tab
TOOLS
OPTIONS
QUERY
(For complete information, refer to: Teradata SQL Assistant for Microsoft Windows - User Guide)
Tools Options Code Editor Tab
TOOLS
OPTIONS
CODE EDITOR
TOOLS
OPTIONS
ANSWERSET
TOOLS
OPTIONS
HISTORY
01 Click-Drag
02 Click-Ctrl-Drag
03 Ctrl-Ctrl-Ctrl-Drag
04 Click-Shift-Click-Drag
Commenting Lines of SQL
Database containing
tables used in the labs.
Database containing
views used in the labs.
True or False:
1. Logon to SQL Assistant and review the option in the TOOLS pull down
menu.
Next, see if you can successfully perform the List Columns option.
Choose a database and a table name based on what you have learned about
the lab environment.
Note the options for Explorer Tree and History. Click on each of these
and note the indentations to show whether they are turned on or not.
Module 1: Lab Exercises (continued)
3. Try each of the following in the order shown, and note if it fails by looking
at the bottom-left portion of the utility screen. For those that fail, double-
click the Notes field for the failed request in the History Window.
HELP DATABASE;
HELP DATABASE yourusername;
DATABASE yourusername;
SHOW TABLE Employee;
DATABASE Employee_Sales;
SHOW TABLE Employee;
4. Practice dragging and dropping columns from the Explorer Tree window
onto the Query Window.