Teradata SQL Quick Reference Guide: Simplicity by Design, Second Edition
Teradata SQL Quick Reference Guide: Simplicity by Design, Second Edition
Edition
by Tom Coffing, Michael Larkins and Steve Wilmes
Coffing Data Warehousing. (c) 2006. Copying Prohibited.
TeradataSQLQuickReferenceGuide:SimplicitybyDesign,SecondEdition
User
Table
Volatile Table
View
Macro
Procedure
Trigger
Column
Index
Statistics
Session
HELP Column
Course_Table.Course_Name;
HELP Session;
HELP 'SQL | <Function>';
HELP 'SQL Create';
A common problem is that an object does not exist. Object <object-name> does not exist.
Solutions:
The easiest and quickest solution is to execute the HELP DATABASE <database-name> command to see what objects are in the database. You
might have misspelled the object name or are pointing to the wrong database. The HELP SESSION command will tell you what Database you are
currently in.
SHOW
Teradata will return the actual DDL/Create Text for the given object in the SQL. This is handy if a user needs to create an object identical or
similar in structure. You can also use this to see what indexes are on a table.
SHOW <OBJECT> <object name>;
Object Choices:
Table
View
Macro
Trigger
Procedure
Object does not exist error code: <object-type> <object-name> does not exist.
Page 2 / 3
Reprintedforibm\[email protected],IBM
CoffingDataWarehousing,CoffingPublishing(c)2006,CopyingProhibited
TeradataSQLQuickReferenceGuide:SimplicitybyDesign,SecondEdition
Solutions:
The first item is to check the spelling of the <object-name> to ensure proper spelling. The next choice is to simply run the HELP DATABASE
<database-name> command to get a list of all the objects in the database where you believe the object is located. You can also see which database
you are currently point to with the HELP SESSION command.
Hint - Man The SHOW command is great if you want to see columns definitions, what indexes are defined, and any constraints in the
table. If you have to change a view, macro, or stored procedure with the replace command it is a great idea to do the show
command and then copy the current structure to make the necessary changes.
EXPLAIN
Returns the Optimizer's plan of how the Teradata system will perform the given SQL request. This plan will include information on indexes
being used, estimated time for query execution, estimated range of rows returned, and information about the spool space used during the
query.
EXPLAIN <SQL command>;
EXPLAIN
SELECT * FROM Student_Course_Table;
EXPLAIN
SELECT last_name, first_name
FROM Employee_Table
WHERE Salary > 45000;
EXPLAIN
SELECT Customer_Number, Customer_Name
FROM Customer_Table AS a INNER JOIN Order_Table AS b
ON a.customer_number = b.customer_number;
Hint - Man It is always recommended to run an EXPLAIN on any new query involving large tables, or vital tables that are frequently
accessed. The EXPLAIN will also tell you the strategy for joins or the indexes being utilized for a particular query.
Page 3 / 3
Reprintedforibm\[email protected],IBM
CoffingDataWarehousing,CoffingPublishing(c)2006,CopyingProhibited