From: | Sean Davis <sdavis2(at)mail(dot)nih(dot)gov> |
---|---|
To: | David Gagnon <dgagnon(at)siunik(dot)com> |
Cc: | Postgresql-General list <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Improvement for COPY command .. unless it already exists |
Date: | 2005-04-07 15:04:31 |
Message-ID: | 490bea87b1a7280e7bcfbb466c6fcd60@mail.nih.gov |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Apr 7, 2005, at 10:33 AM, David Gagnon wrote:
> Hi,
>
> I want to default some columns for this COPY command only. So DEFAULT
> is not appropriate in this case. In fact I think you suggested a
> workaround right ? Doing an alter table before and another one after
> will work ... not fully clean thought since my user may not have the
> write to modify the table. Being able to specify default values
> directly in the COPY command will be really nice :-) I just wanted to
> share my tought :-)
>
> Being eable to read zipped file will be cool to .. but I'm not sure
> it's Chrismas yet right so I didn't ask ;-)
>
> Thanks for your help
> /David
David,
If you use a simple wrapper around copy using DBI (as either an
untrusted perl database function) or straight perl, you could read
zipped files as a filehandle.
As for defaults, you could also write a trigger to accomplish the
"default" behavior or, if you use the above perl-based loader, you
could implement defaults as well....
Sean
>
> Tom Lane wrote:
>
>> David Gagnon <dgagnon(at)siunik(dot)com> writes:
>>
>>> Is there a way to specify default values in the COPY command?
>>>
>>
>> There's always ALTER TABLE ... SET DEFAULT.
>>
>> regards, tom lane
>>
>>
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)
From | Date | Subject | |
---|---|---|---|
Next Message | Joel Leyh | 2005-04-07 16:48:54 | seg fault with tsearch2 |
Previous Message | Stephen Frost | 2005-04-07 15:00:00 | Re: WAL on a RAM disk |