[Privileges] -> [Role] -> [User]
Privileges gives permission to access database objects.
https://www.postgresql.org/docs/current/database-roles.html
- A PostgreSQL database by default has
public
schema - Access to
public
schema granted bypublic
role by default. -
User
andRole
can be used interchangeably. - But
User
is aRole
can login. - (Access) Privileges:
SELECT
,INSERT
,UPDATE
,DELETE
,TRUNCATE
,REFERENCES
,TRIGGER
,CREATE
,CONNECT
,TEMPORARY
(orTEMP
),EXECUTE
,USAGE
. There isALL PRIVILEGES
. -
PUBLIC
key word indicates the privileges are to be granted to all roles - Commands:
GRANT
CREATE ROLE user WITH LOGIN PASSWORD 'secret';
-- Schema names you have access
show search_path;
\duS pg_*
See Read-only User.