User
확인
--Shell
\du
--Query
SELECT * FROM PG_USER;
/*
usename | usesysid | usecreatedb | usesuper | userepl | usebypassrls | passwd | valuntil | useconfig
----------+----------+-------------+----------+---------+--------------+----------+----------+-----------
postgres | 10 | t | t | t | t | ******** | |
(1 rows)
*/
SELECT * FROM PG_SHADOW;
생성
CREATE USER user_name PASSWORD 'password' role_name;
/*
CREATE ROLE
*/
삭제
DROP USER user_name;
/*
DROP ROLE
*/
비밀번호 변경
ALTER USER user_name WITH PASSWORD 'new_password';
/*
ALTER ROLE
*/
권한 부여
https://www.postgresql.org/docs/current/sql-createrole.html
CREATE ROLE user_name role_name;
슈퍼유저 권한 부여
ALTER ROLE user_name WITH SUPERUSER;
# RDS PostgreSQL
GRANT rds_superuser TO user_name;
권한 해제
DROP ROLE user_name;