RefLib

Reference library for AI

Back

postgresql_16:9.6.22.2 How to Use It

PostgreSQL 16 > Appendixes > Additional Supplied Modules and Extensions > lo — manage large objects > How to Use It

Here's a simple example of usage:

CREATE TABLE image (title text, raster lo);

CREATE TRIGGER t_raster BEFORE UPDATE OR DELETE ON image
    FOR EACH ROW EXECUTE FUNCTION lo_manage(raster);

For each column that will contain unique references to large objects, create a BEFORE UPDATE OR DELETE trigger, and give the column name as the sole trigger argument. You can also restrict the trigger to only execute on updates to the column by using BEFORE UPDATE OF *column_name*. If you need multiple lo columns in the same table, create a separate trigger for each one, remembering to give a different name to each trigger on the same table.

Back