PostgreSQL: How to Restrict User Access
PostgreSQL: How to Restrict User Access
PostgreSQL allows fine-grained access control using roles and privileges.
Revoke All Access
REVOKE ALL ON DATABASE mydb FROM username;
Grant Read-Only Access
GRANT CONNECT ON DATABASE mydb TO username;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO username;
Prevent Future Table Access
ALTER DEFAULT PRIVILEGES
REVOKE ALL ON TABLES FROM username;
This ensures the user can only read data and not modify it.
Comments
Post a Comment