Skip to content

Instantly share code, notes, and snippets.

@GeoffWilliams
Created November 5, 2021 02:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GeoffWilliams/64ad6e3d58aa8c39dc34070ea3209428 to your computer and use it in GitHub Desktop.
Save GeoffWilliams/64ad6e3d58aa8c39dc34070ea3209428 to your computer and use it in GitHub Desktop.
plpgsql create/alter user
DO
$$BEGIN
IF EXISTS (SELECT FROM pg_roles WHERE rolname = 'my_user') THEN
EXECUTE 'ALTER USER...';
ELSE
EXECUTE 'CREATE USER...';
END IF;
END$$;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment