Skip to content

Instantly share code, notes, and snippets.

@manuwell
manuwell / postgres-dml-role.sql
Created October 21, 2022 16:52
PG - DML only Role Creation script
-- first create a new user if not exists for your app
-- this user will have access only to DML queries (select, update, insert, delete)
DO
$do$
BEGIN
IF NOT EXISTS (
SELECT FROM pg_catalog.pg_roles
WHERE rolname = 'app_user') THEN
CREATE ROLE app_user LOGIN PASSWORD 'PASS';
END IF;