There are server-side functions callable from SQL that
correspond to each of the client-side functions described above;
indeed, for the most part the client-side functions are simply
interfaces to the equivalent server-side functions. The ones that
are actually useful to call via SQL commands are lo_creat,
lo_create, lo_unlink, lo_import,
and lo_export. Here are examples of their use:

The server-side lo_import and
lo_export functions behave
considerably differently from their client-side analogs. These
two 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. The client-side functions can be used by any
PostgreSQL user.

The functionality of lo_read and
lo_write is also available via
server-side calls, but the names of the server-side functions
differ from the client side interfaces in that they do not
contain underscores. You must call these functions as
loread and lowrite.