pg_dump:
pg_dump -a -t tbl_test "host=127.0.0.1 hostaddr=127.0.0.1 port=5432 user=postgres password=123456 dbname=postgres" > /userdir/tbl_data
- -a 参数是表示只导出数据,其他的额外信息不需要,该参数也可去掉
psql:
psql --command "select * from tbl_test;" "host=127.0.0.1 hostaddr=127.0.0.1 port=5432 user=postgres password=123456 dbname=postgres"
需要导出文件的话:
psql -a --command "select * from cdrs limit 1;" "host=127.0.0.1 hostaddr=127.0.0.1 port=5432 user=postgres password=123456 dbname=postgres" > tbl_data.txt