Teradata tips

by Irina 14. March 2009 18:01
    
A database may contain :

Tables – contain data
Views – are previously defined “windows” to the data 
Macros – are stored SQL statements
Triggers – are SQL statements associated with a table
Join indexes – are user defined pre-joins or pre-aggregations
Stored-procedures – are pre-written SQL scripts with defined procedural processing using Stored procedures control statements

 
Definition of  default database:

.logon irena
Password: abc123
The normal default database for this logon is irena until:
    * User logs off
    * A new database control is used
 
The database command used to change default database

You can easily verify you current default database:

Select database
Other build-in function:

Current_date
Current_time
Current_timestamp
Date
Profile
Role
Time
 
Bteq – is a front end tool for submitting SQL queries. Bteq stands for basic Teradata Query programs
There are many tools available to provide help for the Teradata Sql user or programmer

    *         Help command
Provides information on a specified database object.
There are many objects for which help may be requested.

Databases and users

HELP DATABASE
HELP USER


Database Objects

HELP TABLE – shows the name, data type and comment of all columns
HELP VIEW
HELP MACRO
HELP COLUMN
HELP INDEX
HELP STATISTICS
HELP CONSTRAINT
HELP VOLATILE TABLE
HELP JOIN INDEX
HELP HESH INDEX
HELP TRIGGER
HELP PROCEDURE
HELP FUNCTION


    *            Show command
 
SHOW TABLE – shows the most current definition of the table
SHOW VIEW
SHOW JOINT INDEX
SHOW PROCEDURE

Shoes how an object was created, intended as a convenience to the developer

    *         Explain feature

 Shoes how a query will execute in Teradata
It’s recommended to use Explain modifier before the SQL request – to see the plan execution of SQL. Explain function returns the plan how the optimizer will execute the SQL.
For example if you see that you request cause Full-table scan on a big table or cause Cartesian product join without intention – it’s preferable to rewrite request and write more efficient joint.

Explain provides:

    *          Translation of AMP steps
    *          A row count and time estimation for comparison only
    *          Which indexes if any will be used
    *          Whether individual steps will be used in parallel

    About the author

    Irina Spivak Irina Spivak
    Team Leader at G-Stat. More...


    Send mail Email

    Blogroll

      Disclaimer

      The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

      © Copyright 2012

      Sign in

      eXTReMe Tracker