Table Aliasing

Database
Enthusiast

Table Aliasing

Hi,

What is the benefits of using Table aliasing? Can it improve performance?

Thanks,

Moutusi

Tags (1)
3 REPLIES
Junior Contributor

Re: Table Aliasing

Hi Moutusi,

aliases simplify query development, no need to key in that_very_long_tablename all the time.

Enthusiast

Re: Table Aliasing

Thanks Dieter. I just got one info that using table aliasing in multi table join can decrease the spool space occupied and hence improving performace. But was not sure sure about this statement. Is it true?

Junior Contributor

Re: Table Aliasing

Hi Moutusi,

that's definitely false.

There's one specific case where wrong aliases might result in an unwanted cross join (= huge spool):

SELECT table1.col1, -- wrong name, should be t1.col1 instead
t1.col2,
t2.col3
FROM table1 AS t1 JOIN table2 AS t2
ON t1.PK = t2.FK;

A table alias replaces the tablename within that query. Using the original tablename doesn't result in an error message (as it does within most other DBMSes), but it causes a CROSS join.

Teradata was implemented before there was Standard SQL, the initial query language was called

TEQUEL (TEradata QUEry Language), whose syntax didn't require to list tables within FROM.

A simple RETRIEVE table1.col1 carried enough information for the Parser/Optimizer to resolve tablename and columnname.

Within that above example there are 3 tables for the optimizer (t1, t2, table1), but only one join-condition, this results in a CROSS join to the third table.