-
[PostgreSQL] psql 명령어DB/PostgreSQL 2016. 12. 16. 18:02
postgres 데이터베이스에 postgres 유저 접속
$ psql -U postgres -d postgres postgres 사용자의 암호:
psql에 지정한 비밀번호로 접속
$ PGPASSWORD=password psql -U postgres -d postgres psql (9.5.4) 도움말을 보려면 "help"를 입력하십시오. postgres=#
psql에서 query 실행
$ PGPASSWORD=password psql -U postgres -d postgres -c 'select * from test'
psql에서 .sql 파일에 저장되어 있는 쿼리 실행
$ PGPASSWORD=password psql -U postgres -d postgres -f test.sql $ PGPASSWORD=password psql -U postgres -d postgres < test.sql
원격 서버의 postgres 데이터베이스의 postgres 유저 접속
$ psql -h 100.100.100.10 -U postgres -d postgres