Skip to content Skip to sidebar Skip to footer

Changing Column Datatype From Decimal(9,0) To Decimal(15,0)

Can you please help me concerning this matter (I didn´t found it in the Teradata documentation, which is honestly little overwhelming): My table had this column -BAN DECIMAL(9,0)-

Solution 1:

The syntax diagram for ALTER TABLE doesn't seem to support directly changing a column's data type. (Teradata SQL DDL Documentation). COMPRESS 0 compresses zeroes. Teradata supports a lot of different kinds of compression.

Numeric overflow here probably means you've exceeded the range of an integer. To make that part work, just try casting to a bigger data type. (You don't need to change the column's data type to do this.)

selectcast(count(*) asbigint) 
from table_name;

Solution 2:

You asked three different questions:

  1. You cannot change the data type of a column from DECIMAL(9,0) to DECIMAL(15,0). Your best bet would be to create a new column (NEW_BAN), assign values from your old column, drop the old column and rename NEW_BAN back to BAN).

  2. COMPRESS 0 is not a constraint. It means that values of "zero" are compressed from the table, saving disk space.

  3. Your COUNT(*) is returning that error becasue the table has more than 2,147,483,647 rows (the max value of an INTEGER). Cast the result as BIGINT (as shown by Catcall).

And I agree, the documentation can be overwhelming. But be patient and focus only on the SQL titles for your exact release. They really are well written.

Solution 3:

You can not use ALTER TABLE to change the data type from DECIMAL(9,0) to DECIMAL(15,0) because it cross the byte boundary required to store the values in the table. For Teradata 13.10, see the Teradata manual for SQL Data Definition Language Detailed Topics pages 61-65 for more details on using ALTER TABLE to change column data types.

Post a Comment for "Changing Column Datatype From Decimal(9,0) To Decimal(15,0)"