View
218
Download
0
Category
Preview:
Citation preview
8/10/2019 Checklist for Teradata SQLs
1/4
Checklist for Teradata SQLs
18/08/2010
EIS / SP
Jagadeesan. M
jagadeesan.m@tcs.com
TCS Public
mailto:jagadeesan.m@tcs.commailto:jagadeesan.m@tcs.commailto:jagadeesan.m@tcs.com8/10/2019 Checklist for Teradata SQLs
2/4
Following are some of the Checklist needs to be followed while
using Teradata:
1.
The Oracle functions like TO_CHAR, LPAD, RPAD are not supported in Teradata.
Thus this can be achieved by parsing the data programmatic-ally.
2.
Usage of Teradata keywords in queries as an alias name or column name should be
strictly avoided.
Sample keywords Type, Zone, Result, position, queue.
Check the following URL for complete list of keywords:
http://www.teradataforum.com/l030103a.htm
3.
There should not be any SELECT query inside a SELECT clause of a query. Following
query format should be avoided:
SELECT coln1,
(SELECT MAX(bal_amt) from bal_history),
coln3 FROM user_credit_account;
4. While performing ORDER BY for a query having JOIN conditions, use the column
names prefixed with table alias names (avoid using column alias name alone).
Eg: SELECT e.emp_id, e.emp_name, m.emp_name FROM
proj_emp e, proj_manger m WHERE e.mgr_id = m.emp_id
ORDER BY e.emp_name;
// avoid ORDER BY 2;
5.
There should not be any SELECT query immediately after the FROM clause of
parent/main query.
6.
Check whether database schema names are appended prior to all table names
used in the queries.(eg: SchemaName.TableName)
TCS Public
http://www.teradataforum.com/l030103a.htmhttp://www.teradataforum.com/l030103a.htm8/10/2019 Checklist for Teradata SQLs
3/4
7.
Most data, varchar as well as numeric data present in Teradata database were
found to contain blank spaces appended to them. Check whether TRIM function is
used while comparing varchar column values in the WHERE clause of a query.
8.
If your query contains a UNION, MINUS, or INTERSECT operator you can not
reference the column(s) by name in your ORDER BY clause. Only the column
number can be used in the ORDER BY clause.
9. The pseudo column ROWNUM is not supported by Teradata. So, do not use
rownum. The Teradata equivalent for this is:
Oracle:
SELECT * FROM salary WHERE ROWNUM
8/10/2019 Checklist for Teradata SQLs
4/4
Recommended