记录一下pgsql的 导入和导出

本地连接
psql -d dbname -U postgre

远程连接pgsql
psql -h 192.168.0.87 -d dbname -U postgre

http://miao19880124.javaeye.com/blog/778732  这个网址是pqsql常用命令


\d                    查看所有表
\d conf_call          查看表结构


修改字段默认值
alter table conf_call alter column mute_flag set default 1;

pgsql备份数据

/usr/local/pgsql/bin/pg_dump -i --column-inserts --encoding=utf-8 -h localhost -U postgre dbname  > dbname.sql

备份一个表 /usr/local/pgsql/bin/pg_dump -i --column-inserts --encoding=utf-8 -U postgre dbname  -t  table > table.sql

只备份结构 /usr/local/pgsql/bin/pg_dump -i --column-inserts --encoding=utf-8 -h localhost -U postgre dbname -s> dbname.sql  

pg_dump
按行插入   -D, --column-inserts        dump data as INSERT commands with column names

指定编码类型-E, --encoding=ENCODING     dump the data in encoding ENCODING

-C, --create                include commands to create database in dump


删除
/usr/local/pgsql/bin/dropdb -h localhost -U postgre dbname

创建
/usr/local/pgsql/bin/createdb -h localhost -U postgre -E UTF8 -O postgre dbname
导入
/usr/local/pgsql/bin/psql -h localhost -U postgre -d dbname -f  /tmp/dbname.sql


你可能感兴趣的:(table,database,include,远程连接,encoding)