Skip to content

Instantly share code, notes, and snippets.

@yanmhlv
Last active November 17, 2022 18:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yanmhlv/67a5b95c14c1c029b93be676e4cad1dc to your computer and use it in GitHub Desktop.
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
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;
@yanmhlv
Copy link
Author

yanmhlv commented Oct 13, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment