Search Postgresql Archives

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Oct 4, 2011 at 12:24 PM, J.V. <jvsrvcs@xxxxxxxxx> 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.,

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux