Teradata behaviour on the tables in the same database.

Database
The Teradata Database channel includes discussions around advanced Teradata features such as high-performance parallel database technology, the optimizer, mixed workload management solutions, and other related technologies.

Teradata behaviour on the tables in the same database.

Need help in one understanding the behaviour of a query.

 

SELECT TAB1.KEY FROM DB.TAB2 

 

Here TAB1 and TAB2 are in Same Database(DB) and Coulmn KEY is present in both tables.

 

My question is, it possible pull KEY data from TAB1 by not including it in FROM CLAUSE. If so, how the query behaves?

 

Do we have any article or documentation on this? If yes, Could you please point me to that link?

 

I am working on such query where we are pulling data from another table/View but we have not mentioned that table/Veiw in FROM CLAUSE. it is working fine and I am unable to get the behaviour of it.

 

Thank you so much in Advance.

 

 

 

2 REPLIES 2
Ambassador

Re: Teradata behaviour on the tables in the same database.

Ambassador

Re: Teradata behaviour on the tables in the same database.

Hi,

 

Yes it is possible, the bit of information that you are probably missing is that in SQL the FROM clause is optional. It is highly recommended to use it, but it is not required. See SQL DML manual for syntax diagram.

 

So the following two queries are identical in terms of functionality.

 

SELECT t1.col1;

SELECT col1 FROM t1;

And with Teradata these two queries will generate the same plan.

 

 

In your example query below, the code will run but you'll get a cartesian product join between the two tables (TAB1 and TAB2).

 

Your query will be treated as the following:

SELECT a.KEY

FROM DB.TAB2

CROSS JOIN TAB1 as a;

 

HTH

Dave

 

Ward Analytics Ltd - information in motion
www: http://www.ward-analytics.com