shell을 이용한 DB query

오늘은 리눅스(Linux)에서 쉘 스크립트(shell script)를 이용하여 PostgresqlDB query 실행하는 방법에 대해 포스팅 하려고 합니다. vi 편집기로 쉘 확장자(.sh)의 파일을 생성 및 편집합니다. vi testdb.sh 내용에 간단한 조회에 대한 아래와 같은 구문을 넣어보겠습니다. su - [DB계정] -c 'psql -d [DB명] -c [query]' su - postgres -c 'psql -d "clovirvdi_multi_nic" -c "select * from cr_vcenter"' 저장을 하고 스크립트를 실행하면 쿼리에 대한 결과를 확인 할 수 있습니다. ./testdb.sh [root@clovirvdi scripts]# ./testdb.sh vcenter_seq |..
보노보노92
'shell을 이용한 DB query' 태그의 글 목록