Thread: Copying data from one column to another

Copying data from one column to another

From
"Nels Lindquist"
Date:
Hi there.

Sorry if this is a silly question, I'm relatively new to PostgreSQL.

I'm trying to copy information from one column, modify it and place
it in another column.  Is there some shortcut way to do this with an
UPDATE statement?

So far I'm thinking I'll need to copy the table schema and then
INSERT...SELECT using the desired expressions.  Does that seem
reasonable?

----
Nels Lindquist <*>
Information Systems Manager
Morningstar Air Express Inc.


Re: Copying data from one column to another

From
Tino Wildenhain
Date:
Am Dienstag, den 01.11.2005, 16:03 -0700 schrieb Nels Lindquist:
> Hi there.
>
> Sorry if this is a silly question, I'm relatively new to PostgreSQL.
>
> I'm trying to copy information from one column, modify it and place
> it in another column.  Is there some shortcut way to do this with an
> UPDATE statement?

Yes, this is simply UPDATE.

UPDATE sometable SET somecolumn=somefunction(someothercolumn);




Re: Copying data from one column to another

From
"Nels Lindquist"
Date:
On 2 Nov 2005 at 0:34, Tino Wildenhain wrote:

> Am Dienstag, den 01.11.2005, 16:03 -0700 schrieb Nels Lindquist:
> > Hi there.
> >
> > Sorry if this is a silly question, I'm relatively new to PostgreSQL.
> >
> > I'm trying to copy information from one column, modify it and place
> > it in another column.  Is there some shortcut way to do this with an
> > UPDATE statement?
>
> Yes, this is simply UPDATE.
>
> UPDATE sometable SET somecolumn=somefunction(someothercolumn);

Thanks!  Knowing that it *should* work, I was able to figure out what
I was doing wrong (casting to a data type which didn't match the
array type I'd accidentally selected when creating the column with
pgAdmin III).

----
Nels Lindquist <*>
Information Systems Manager
Morningstar Air Express Inc.