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.)
There is once more function available:
SELECT lo_unlink(image.raster) FROM image WHERE name = \'beautiful image\';
Obviously, it removes the object from the database structure.