DataBase/PostgreSQL

psql 문법

레알윙 2020. 6. 4. 16:54
반응형

우선 회사에서 주로 사용하는 문법에 대해 정리해보자..

 

postgres DB에  postgre 유저 접속

$psql -h 127.0.0.1 -U postgre -d postgres
비번 입력 1234

 

psql에 지정한 비밀번호로 접속

$ PGPASSWORD=password psql -U postgres -d postgres

 

psql 에서 .sql파일에 저장되어 있는 쿼리 실행

$ PGPASSWORD=password psql -U postgres -d postgres -f test.sql
$ PGPASSWORD=password psql -U postgres -d postgres < test.sql

$ psql -h 127.0.0.1 -U postgres -d postgres < test.sql
비밀번호 입력

 

원격 서버의 postgres 데이터베이스의 postgres유저 접속

psql -h 100.100.100.10 -U postgres -d postgres

 

 

참고

https://brownbears.tistory.com/223

반응형