데이터베이스/Postgresql

postgresql 기초 명령어

글을 쓰는 개발자 2021. 7. 5. 12:02
반응형

cli로 postgresql 접속

sudo -i -u postgres psql

 

 

유저 생성/ 데이터베이스 생성/ 권한 부여

postgres# CREATE USER ${user} PASSWORD '${password}';
postgres# CREATE DATABASE ${db_name} ENCODING 'utf-8';
postgres# ALTER DATABASE ${db_name} OWNER TO ${user};

 

유저 조회

select * from pg_shadow;

 

search_path 변경

ALTER ROLE ${name} SET search_path TO ${schema};

 

데이터베이스 접속

\c <your-database-name>
반응형