I need your help
I need your help

Reputation: 17

Sql alter column value without deleting the old one

Is there some way of on a certain table column add an value to the column but keeping the old value?

I have this:

 id | dateB/dateE  |
 1  | 2018-07-05   | 
 2  | 2018-07-05   |

I want after an update:

 id | dateB/dateE             |
 1  | 2018-07-05/ 2018-07-06  | 
 2  | 2018-07-05/ 2018-07-06  | 

Upvotes: 0

Views: 721

Answers (2)

Gordon Linoff
Gordon Linoff

Reputation: 1271151

A better solution:

alter table t add column dateB date;
alter table t add column dateE date;

update t
    set dateB = col2,
        dateE = date '2018-07-06';

alter table t drop column col2;

That is, store values using the correct types.

Upvotes: 2

The Impaler
The Impaler

Reputation: 48875

How about:

update my_table set col2 = col2 || '/ 2018-07-06';

Upvotes: 1

Related Questions