Re: how to select one column into another in same table?

From: "J(dot)V(dot)" <jvsrvcs(at)gmail(dot)com>
To:
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: how to select one column into another in same table?
Date: 2011-10-04 19:21:37
Message-ID: 4E8B5CC1.20208@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

What I need to do is to save the id column for future use and then
modify the id column resetting all values from another sequence.

So I need to select the id column or somehow get the data into another
column in the same table.

And then I can update the id column (after dropping the constraint).

J.V.

On 10/4/2011 1:09 PM, Scott Marlowe wrote:
> On Tue, Oct 4, 2011 at 12:24 PM, J.V.<jvsrvcs(at)gmail(dot)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.,
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Guillaume Lelarge 2011-10-04 19:39:59 Re: fail: alter table <table_name> NOCHECK CONSTRAINT ALL;
Previous Message J.V. 2011-10-04 19:20:20 Re: fail: alter table <table_name> NOCHECK CONSTRAINT ALL;