Large Object Functions

Table 3-22. Large Object Functions

NameReturn typeDescription
lo_import(filename)oidImport LOB
lo_export(filename)oidExport LOB

There are two built-in registered functions, lo_import and lo_export, that can be used in SQL queries to omport and export large objects (LOBs). The filename argument specifies the UNIX pathname of the file to be imported as a large object (or the location of the file the LOB should be exported to).

They can be used as follows:
CREATE TABLE image (
    name    text,
    raster  oid
);
INSERT INTO image (name, raster);
    VALUES ('beautiful image', lo_import('/etc/motd'));
SELECT lo_export(image.raster, 'tmp/motd') from image
    WHERE name = 'beautiful image';