Re: how to select one column into another in same table? - Mailing list pgsql-general

From Scott Marlowe
Subject Re: how to select one column into another in same table?
Date
Msg-id CAOR=d=14GyurSZ0e-j5O7ordmrvNT1F=qN853VR0vdasz2d8WQ@mail.gmail.com
Whole thread Raw
In response to how to select one column into another in same table?  ("J.V." <jvsrvcs@gmail.com>)
Responses Re: how to select one column into another in same table?  ("J.V." <jvsrvcs@gmail.com>)
List pgsql-general
On Tue, Oct 4, 2011 at 12:24 PM, J.V. <jvsrvcs@gmail.com> wrote:
> Currently I can select one column into another with two statements:
>
>    alter table <table_name> add column id_old int;
>    update <table_name> set id_old = id;
>
> Is there a way to do this in one statement with a select into?  I have tried
> various select statements but want the new column (with the same data) to be
> in the same table and to have it execute much more quickly that the two
> statements currently do.

Do you need another column or do you just want to alter a column that
already exists?  If so you can alter a column from one type to another
and throw a using clause at it to convert the data in some way.  I
think we need to know a bit better what you're trying to do.,

pgsql-general by date:

Previous
From: "J.V."
Date:
Subject: how to select one column into another in same table?
Next
From: Guillaume Lelarge
Date:
Subject: Re: fail: alter table NOCHECK CONSTRAINT ALL;