From: | "John Skillings" <jskillings07(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Copying Blobs between two tables using Insert stmt |
Date: | 2008-10-17 20:18:56 |
Message-ID: | caad18b00810171318t26d60f53w6f8ec74d3cb03674@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi all,
I am trying to copy blobs between two tables and need help on the best way
to get this done. My requirement is that the both the tables maintain their
own copy of the large object, instead of sharing the OID.
I created two tables:
create table table_a
(id bigserial not null,
filename oid);
create table table_b
(id bigserial not null,
filename oid);
In one of the tables, I uploaded a file from the filesystem.
INSERT INTO table_a (id, filename)
VALUES ( nextval('table_a_id_seq'),
lo_import('C:/applications/largeobj.zip'));
The record is inserted, and I verified the record's integrity by:
SELECT lo_export(filename, 'C:/applications/largeobj.zip_copy.zip') FROM
table_a;
Question
----------------
Now to make a copy of the object from table to table_a to table_a. Currently
I am exporting the file from table_a to the file system, and again doing an
import into table_b. However, in a large application, I find this
workaround not practical because of the volume of the records, and also the
size of the file (binary object). My ideal solution to do an insert of the
values from table_a into table_b directly.
So, what is best way to create a copy of this LOB from table_a to table_b?
Appreciate any responses.
Thank you.
John
From | Date | Subject | |
---|---|---|---|
Next Message | John Skillings | 2008-10-17 20:37:52 | Re: Copying Blobs between two tables using Insert stmt |
Previous Message | Jason Long | 2008-10-17 20:17:06 | Re: Annoying Reply-To |