From 905c478409aa77d2dc061f6962ae5bec0c0b1020 Mon Sep 17 00:00:00 2001 From: Michele Cereda Date: Fri, 12 Dec 2025 18:20:46 +0100 Subject: [PATCH] chore(postgresql): add commands related to privileges --- snippets/postgres/primer.sql | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/snippets/postgres/primer.sql b/snippets/postgres/primer.sql index f7a43c1..43707e4 100644 --- a/snippets/postgres/primer.sql +++ b/snippets/postgres/primer.sql @@ -222,14 +222,24 @@ SELECT grantor, grantee, table_schema, table_name, privilege_type FROM information_schema.table_privileges WHERE grantee = 'engineers'; +-- default privileges +\ddp +\ddp public --- Assign permissions + +-- Assign permissions on existing resources +-- Will *not* work on future resources +-- Refer GRANT USAGE ON SCHEMA bar_schema TO donald; GRANT ALL PRIVILEGES ON foo_table TO jonathan; GRANT admins TO joe; -GRANT SELECT, INSERT ON foo_table IN SCHEMA public TO kevin; +GRANT SELECT, INSERT ON ALL TABLES IN SCHEMA public TO kevin; +GRANT ALL ON TABLE public.assignments TO kevin; GRANT SELECT (col1), UPDATE (col1) ON ALL TABLES IN SCHEMA public TO zoe; -ALTER DEFAULT PRIVILEGES IN SCHEMA bar_schema GRANT SELECT ON TABLES TO foo; + +-- Assign permissions on existing and future resources +-- Refer +ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO bar; -- Close the connection to the current DB