Last active
November 17, 2022 18:38
-
-
Save yanmhlv/67a5b95c14c1c029b93be676e4cad1dc to your computer and use it in GitHub Desktop.
create user, set password, grand and revoke access to certain and all tables
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE USER admin; -- create user with name 'admin' | |
ALTER USER admin WITH PASSWORD 'hello123'; -- set password | |
GRANT SELECT ON users TO admin; -- give 'select' access on 'users' table to 'admin' user | |
REVOKE SELECT ON users FROM admin; -- revoke access on 'users' table from 'admin' user | |
GRANT SELECT ON ALL TABLES IN SCHEMA public TO admin; -- give access to all tables in public schema to 'admin' user | |
REVOKE ALL ON ALL TABLES IN SCHEMA public FROM admin; -- revoke access on all tables from 'admin' user | |
DROP USER admin; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://www.postgresqltutorial.com/postgresql-roles/