Teradata Implicit Casting

Database
Teradata Employee

Teradata Implicit Casting

Hi,

I was just curious to know what would happen when 2 columns with different data types integer and byteint is joined together?

According to me the byteint should be converted to integer. However I believe I read somewhere that they are both converted to FLOAT.

Please help.  

4 REPLIES

Re: Teradata Implicit Casting

Hi,

What do you mean by "joined together". does it mean concat?

if it is concat then you can check it by using 

select type(cast(123456 as integer)||cast(123 as byteint))
Teradata Employee

Re: Teradata Implicit Casting

No.

Say 2 tables table_a with column a byteint and other table_b with column b integer

When they are joined together :

Select * from table_a join table_b on table_a.a=table_b.b

What is the implicit casting going on ?

Teradata Employee

Re: Teradata Implicit Casting

See the "Implicit Type Conversion of Comparison Operands" topic in SQL Reference: Functions, Operators, Expressions, and Predicates manual.

In general, comparing (or joining on) two numeric columns works as you expect. For example, BYTEINT will be implicitly converted to INTEGER for comparison.

But if you compare a numeric column with a character column, Teradata attempts to convert both to FLOAT.

Teradata Employee

Re: Teradata Implicit Casting

Thanks Fred. This document contains everything :)