Warm tip: This article is reproduced from stackoverflow.com, please click
postgresql

Duplicate column with different name

发布于 2020-03-27 10:19:49

I have a column on my table called RecordId. I want to duplicate this column to a column named BookId. I know I can add column like this:

ALTER TABLE products ADD COLUMN BookId;

But how do I populate the value from the other column?

Questioner
Guerrilla
Viewed
75
7,437 2019-07-03 22:08
UPDATE products 
SET BookId = RecordId
WHERE RecordId > 0