Database

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

10-17-2010
08:32 PM

10-17-2010
08:32 PM

Hi All,

I have a question regarding the teradata datatypes.

The question is why do we need integer datatypes when the same purpose is being served in by decimal(n,0).

I do read that there is no advantage in termes of storage space as both are stored as 2's complementay form results in occupying the same amount of space.If my understanding is wrong or if there are any other advantages kindly let me know.

Please let me know if you need any more information.

Thanks in advance

Manu

I have a question regarding the teradata datatypes.

The question is why do we need integer datatypes when the same purpose is being served in by decimal(n,0).

I do read that there is no advantage in termes of storage space as both are stored as 2's complementay form results in occupying the same amount of space.If my understanding is wrong or if there are any other advantages kindly let me know.

Please let me know if you need any more information.

Thanks in advance

Manu

4 REPLIES

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

10-18-2010
12:17 AM

10-18-2010
12:17 AM

Hi Manu,

it's better to have more choices available :-)

Differences which come to mind:

- integers are truncated, but decimals are rounded, e.g. select 2/3 vs. select 2./3.

- the range of values is larger for integers with the storage size, e.g. byteint: -128..128, dec(2,0): -99..99

Dieter

it's better to have more choices available :-)

Differences which come to mind:

- integers are truncated, but decimals are rounded, e.g. select 2/3 vs. select 2./3.

- the range of values is larger for integers with the storage size, e.g. byteint: -128..128, dec(2,0): -99..99

Dieter

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

10-18-2010
04:06 AM

10-18-2010
04:06 AM

My undesrstading is even for dec(2,0) the maximum positive value that can be stored is 127 sice the decimal datatypes are stored as binary 2's complementay form and the range of values that are stored if I have a byte which is 8 bits is -2^8 to {(2^8) - 1} which means -128 to 127 (2^8 - 1).

Please correct me if my understading is wrong.

Please correct me if my understading is wrong.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

10-18-2010
04:24 AM

10-18-2010
04:24 AM

I have just now verified by creating a sample table with dec(2,0) and tried to insert digits 100,110,127.

But I could not succeed.I still wonder bcz the teradata document (The one which I got along with installation) says the internal storage format is 2's complementary but practically it is not allowing me store the digits >99 and < 127.

Now I really wannna know how would be the storage of decimal datatypes in teradata.

Any help would be appreciated.

But I could not succeed.I still wonder bcz the teradata document (The one which I got along with installation) says the internal storage format is 2's complementary but practically it is not allowing me store the digits >99 and < 127.

Now I really wannna know how would be the storage of decimal datatypes in teradata.

Any help would be appreciated.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

10-18-2010
05:36 AM

10-18-2010
05:36 AM

Hi Manu,

the maximum to be stored for 2 byte integer is 127, so in theory this could be stored in a dec(2,0), but 127 are 3 digits and and dec(2,0) only defines 2 digits, so 127 simply doesn't fit.

A decimal is stored as a scaled integer, i.e. a dec(4,2) is stored as "value * 100".

1..2 digits -> 1 byte

3..4 -> 2

5..9 -> 4

10..18 -> 8

19..38 -> 16

Did you happen to work with Oracle before? Those NUMBERs are quite proprietary :-)

Dieter

the maximum to be stored for 2 byte integer is 127, so in theory this could be stored in a dec(2,0), but 127 are 3 digits and and dec(2,0) only defines 2 digits, so 127 simply doesn't fit.

A decimal is stored as a scaled integer, i.e. a dec(4,2) is stored as "value * 100".

1..2 digits -> 1 byte

3..4 -> 2

5..9 -> 4

10..18 -> 8

19..38 -> 16

Did you happen to work with Oracle before? Those NUMBERs are quite proprietary :-)

Dieter