agora inbox for pgsql-sql@postgresql.org
help / color / mirror / Atom feedFrom: Eugene Yin <eugeneymail@ymail.com>
To: Andreas Joseph Krogh <andreas@visena.com>
Cc: Postgres List <pgsql-sql@postgresql.org>
Subject: Re: BYTEA vs BLOB
Date: Sun, 17 Jan 2016 16:56:33 +0000 (UTC)
Message-ID: <1487961919.5778438.1453049793112.JavaMail.yahoo@mail.yahoo.com> (raw)
In-Reply-To: <VisenaEmail.a0.92ae40c7c924b9ef.15250188270@tc7-visena>
References: <VisenaEmail.a0.92ae40c7c924b9ef.15250188270@tc7-visena>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-sql>
lfd := lo_open(loid,131072);
Why use the file size 131072, instead of other number?Are there other options? I mean, under what circumstance, use 131072, or use other size?
Thanks
Eugene
On Sunday, January 17, 2016 7:02 AM, Andreas Joseph Krogh <andreas@visena.com> wrote:
På lørdag 16. januar 2016 kl. 17:08:05, skrev Eugene Yin <eugeneymail@ymail.com>:
When use Ora2Pg to migrate the Oracle to Pg, the BLOB data type in Oracle will supposedly be converted into BYTEA in Pg. Is this achievable? If so, after the data become BYTEA, can I further convert the BYTEA into OID data type, and how to?
Here's how I converted a BYTEA-column to OID: The table origo_file_rawdata contains a column named 'data' of type BYTEA. The trick is to add a new column, 'lo_data' of type=OID, populate it, then drop the old column and rename 'lo_data' to 'data':begin;
alter table origo_file_rawdata add column lo_data oid;
do $$
declare
loid oid;
lfd integer;
lsize integer;
d origo_file_rawdata;
begin
for d IN (select * from origo_file_rawdata) loop
loid := lo_create(0);
lfd := lo_open(loid,131072);
lsize := lowrite(lfd, d.data);
perform lo_close(lfd);
update origo_file_rawdata set lo_data = loid where entity_id = d.entity_id;
end loop;
end;
$$;
alter table origo_file_rawdata alter column lo_data set not null;
alter table origo_file_rawdata drop column data;
alter table origo_file_rawdata rename lo_data to data;
commit;
Hope this helps. --Andreas Joseph KroghCTO / Partner - Visena ASMobile: +47 909 56 963andreas@visena.comwww.visena.com
=
--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql
view thread (8+ messages) latest in thread
Message-ID: <1487961919.5778438.1453049793112.JavaMail.yahoo@mail.yahoo.com>
Permalink: ../1487961919.5778438.1453049793112.JavaMail.yahoo@mail.yahoo.com/
Also on: postgresql.org/message-id/1487961919.5778438.1453049793112.JavaMail.yahoo@mail.yahoo.com
reply
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: eugeneymail@ymail.com, andreas@visena.com
Subject: Re: BYTEA vs BLOB
In-Reply-To: <1487961919.5778438.1453049793112.JavaMail.yahoo@mail.yahoo.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox