From: | Eugene Yin <eugeneymail(at)ymail(dot)com> |
---|---|
To: | Andreas Joseph Krogh <andreas(at)visena(dot)com> |
Cc: | Postgres List <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: BYTEA vs BLOB |
Date: | 2016-01-17 16:56:33 |
Message-ID: | 1487961919.5778438.1453049793112.JavaMail.yahoo@mail.yahoo.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-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(at)visena(dot)com> wrote:
På lørdag 16. januar 2016 kl. 17:08:05, skrev Eugene Yin <eugeneymail(at)ymail(dot)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(at)visena(dot)comwww(dot)visena(dot)com
Attachment | Content-Type | Size |
---|---|---|
|
image/png | 1.9 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Andreas Joseph Krogh | 2016-01-17 17:01:36 | Re: BYTEA vs BLOB |
Previous Message | Eugene Yin | 2016-01-17 16:28:28 | tablespace |