1. 기본

LOCK TABLE {스키마}.{테이블} IN ACCESS EXCLUSIVE MODE;
LOCK TABLE {스키마}.{테이블} IN SHARE UPDATE EXCLUSIVE MODE;

2. 응용: 스키마 단위 락

BEGIN;

DO $$
DECLARE
    r RECORD;
    s VARCHAR DEFAULT 'public';
BEGIN
    FOR r IN (SELECT tablename FROM pg_tables WHERE schemaname = s) LOOP
        EXECUTE 'LOCK TABLE ' ||  s || '.' || r.tablename || ' IN SHARE UPDATE EXCLUSIVE MODE';
    END LOOP;
END $$;

-- DO SOMETHING HERE --

COMMIT;