Change column type from Date to Timestamp

Database
Enthusiast

Change column type from Date to Timestamp

I am working on Teradata where we have a date column. Initially I was trying to add Time to this, but it didn't work. Is there any way I can add Time to the date format or atleast convert it to Timestamp. Thank you. Here is what I tried.

 

ALTER TABLE TABLE_NAME ADD COLUMN_NAME timestamp(0);

ALTER TABLE TABLE_NAME modify COLUMN_NAME DATE FORMAT 'DD.MM.YYYY'  DATE FORMAT 'DD.MM.YYYY HH:MM:SS';

Any ideas? Thank you.

1 REPLY
Teradata Employee

Re: Change column type from Date to Timestamp

You can't change the data type of an existing column.

 

Generally your best option is to create a new table and copy (INSERT/SELECT) the data.

 

In some cases, it might make sense to use ALTER to add a new column, and use UPDATE to populate it (and perhaps also rename or drop the old column).