본문 바로가기
Server/Ubuntu

POSTGRESQL import export

by 유주원 2014. 2. 28.

POSTGRESQL 생각보다 번거롭다!!!


일단 테이블 데이터들을 export 하는 방법

pg_dump -a --host [호스트네임] --port [포트번호] --username [DB 사용자 이름] -Fc -f [export 결과 파일명] -t [테이블명] [DB명]

ex) pg_dump -a --host test.net --port 1234 --username test -Fc -f tb_test.mydb -t public.tb_test db_test


export file을 import 하는 방법

pg_restore -h localhost -U [DB 사용자 이름] -Fc -d [DB 명] [import 할 파일 명]

ex) pg_restore -h localhost -U test -Fc -d db_test tb_test.mydb