From: C. Bensend <benny@bennyvision.com>
To: pgsql-sql@postgresql.org
Subject: Stuffing six separate columns into a single array?
Date: Mon, 4 Oct 2004 22:56:20 -0500 (CDT)
Message-ID: <64789.63.227.74.41.1096948602.squirrel@63.227.74.41> (raw)
Hey folks,
I'm in the middle of a database design update, mostly to undo all of
the stupid things I did in version 0.01. :) God knows I made enough
of them...
I have a table with the following columns:
dns1_ptr | inet | default '0.0.0.0'::inet
dns2_ptr | inet | default '0.0.0.0'::inet
dns3_ptr | inet | default '0.0.0.0'::inet
dns4_ptr | inet | default '0.0.0.0'::inet
dns5_ptr | inet | default '0.0.0.0'::inet
dns6_ptr | inet | default '0.0.0.0'::inet
(yes, I know, I didn't know any better)
It is being replaced by:
dns_ptr | inet[] | default ...etc
(hopefully this is more intelligent)
Now, as I migrate the data from the old table to the new, is there
any way to just do the typical 'INSERT INTO blah SELECT a,b,c FROM blah2'
type of thing? ie,
INSERT INTO new_table ( dns_ptr ) SELECT dns1_ptr, dns2_ptr .. FROM
old_table;
I can't seem to get the CASTing right on the SELECT statement, but
perhaps it's not even possible. It would be nice to be able to do
this so I don't have to write yet another perl script. I thought a
'CAST( '{dns1_ptr, dns2_ptr}' AS inet[] )' would work, but it complained
about the input syntax on dns1_ptr. I'm learning as I go, so maybe
that's not even close to being valid.
Any help/advice would be greatly appreciated,
Benny
--
"Even if a man chops off your hand with a sword, you still have two nice,
sharp bones to stick in his eyes."
-- .sig on Slashdot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: benny@bennyvision.com
Subject: Re: Stuffing six separate columns into a single array?
In-Reply-To: <64789.63.227.74.41.1096948602.squirrel@63.227.74.41>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox