How to change DECIMAL(18,2) to DOUBLE in an EXISTING Table in Teradata please advise.

Database
rs2
Enthusiast

How to change DECIMAL(18,2) to DOUBLE in an EXISTING Table in Teradata please advise.

How to change DECIMAL(18,2) to DOUBLE in an EXISTING Table in Teradata please advise.

1 REPLY
Enthusiast

Re: How to change DECIMAL(18,2) to DOUBLE in an EXISTING Table in Teradata please advise.

CREATE TABLE TEST_A
(
COL1 VARCHAR (10),
COL2 DECIMAL (18, 2)
);

INSERT INTO TEST_A VALUES ('A', 1.23);
INSERT INTO TEST_A VALUES ('B', 2.34);
INSERT INTO TEST_A VALUES ('C', 3.45);
INSERT INTO TEST_A VALUES ('D', 4.56);
INSERT INTO TEST_A VALUES ('E', 5.67);
INSERT INTO TEST_A VALUES ('F', 6.78);
INSERT INTO TEST_A VALUES ('G', 7.89);
INSERT INTO TEST_A VALUES ('H', 8.93);
INSERT INTO TEST_A VALUES ('I', 9.2);
INSERT INTO TEST_A VALUES ('J', 1);

SELECT * FROM TEST_A;

CREATE TABLE TEST_B
(
COL1 VARCHAR (10),
COL2 DOUBLE
);

INSERT INTO TEST_B SELECT * FROM TEST_A;

SELECT * FROM TEST_B;

DROP TABLE TEST_A;

RENAME TEST_B TO TEST_A;

 

This above would be my approach. Please check the below posts. You may get some more ideas.

http://community.teradata.com/t5/Database/How-to-modify-datatype-of-a-column-using-alter-table-comma...

http://community.teradata.com/t5/Database/Changing-column-datatype-from-DECIMAL-9-0-to-DECIMAL-15-0/...