Supported Versions: Current (16) / 15 / 14 / 13 / 12
Development Versions: devel
Unsupported versions: 11 / 10 / 9.6 / 9.5 / 9.4 / 9.3 / 9.2 / 9.1 / 9.0 / 8.4 / 8.3 / 8.2 / 8.1 / 8.0 / 7.4 / 7.3 / 7.2 / 7.1
This documentation is for an unsupported version of PostgreSQL.
You may want to view the same page for the current version, or one of the other supported versions listed above instead.

28.4. Server-Side Functions

There are two built-in server-side functions, lo_import and lo_export, for large object access, which are available for use in SQL commands. Here is an example of their use:

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';

These functions read and write files in the server's file system, using the permissions of the database's owning user. Therefore, their use is restricted to superusers. (In contrast, the client-side import and export functions read and write files in the client's file system, using the permissions of the client program. Their use is not restricted.)