DataBase/Postgresql
docker 기반 postgreSQL 접속하기
태하팍
2022. 4. 4. 11:19
반응형
목표 :
docker 컨테이너가 띄워져있다는 전제하에 postgresql에 접속을 해서 테이블을 조회 해보자
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
13e2af478713 postgres "docker-entrypoint.s…" 11 days ago Up 11 days 0.0.0.0:5432->5432/tcp, :::5432->5432/tcp rest
접속
docker exec -i -t rest bash
데이터베이스 보기
/l
postgres-# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+------------+------------+-----------------------
postgres | postgres | UTF8 | en_US.utf8 | en_US.utf8 |
template0 | postgres | UTF8 | en_US.utf8 | en_US.utf8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.utf8 | en_US.utf8 | =c/postgres +
| | | | | postgres=CTc/postgres
(3 rows)
테이블 보기
\dt
postgres-# \dt
List of relations
Schema | Name | Type | Owner
--------+---------------+-------+----------
public | account | table | postgres
public | account_roles | table | postgres
public | event | table | postgres
(3 rows)
account table 조회
postgres=# select * from account;
id | email | password
----+-------------------+----------------------------------------------------------------------
1 | sshaple@naver.com | {bcrypt}$2a$10$FvQR3sdpfTbS.Cw7LWvijeXbomulmvi6aw.65SuCwAf1XbZwxtG3G
(1 row)
반응형