Grant access privileges on objects created in the future.
suggest changeSuppose, that we have three users
:
- The Administrator of the database >
admin
- The application with a full access for her data >
read_write
- The read only access >
read_only
With below queries, you can set access privileges on objects created in the future in specified schema.
ALTER DEFAULT PRIVILEGES IN SCHEMA myschema GRANT SELECT ON TABLES TO read_only;
ALTER DEFAULT PRIVILEGES IN SCHEMA myschema GRANT SELECT,INSERT,DELETE,UPDATE ON TABLES TO read_write;
ALTER DEFAULT PRIVILEGES IN SCHEMA myschema GRANT ALL ON TABLES TO admin;
Or, you can set access privileges on objects created in the future by specified user.
ALTER DEFAULT PRIVILEGES FOR ROLE admin GRANT SELECT ON TABLES TO read_only;
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents