
Postgresql
数据的导入和导出,以及copy命令介绍\x0d\x0a\x0d\x0a如何导出PostgreSQL
数据库中的数据:\x0d\x0apg_dump -U postgres -f dump.sql mydatabase\x0d\x0a具体某个表\x0d\x0apg_dump -U postgres -t mytable -f dump.sql mydatabase\x0d\x0a\x0d\x0a导入数据时首先创建数据库再用psql导入:\x0d\x0acreatedb newdatabase\x0d\x0apsql -d newdatabase -U postgres -f dump.sql\x0d\x0a\x0d\x0a把数据按照自己所想的方式导出,强大的copy命令:\x0d\x0aecho "copy students to? stdout DELIMITER '|'"|psql school|head\x0d\x0a(students为表名,school为库名,各个字段以|分隔)\x0d\x0aecho 'copy (select * from students order by age limit 10) to stdout' | psql school导出整个数据库 pg_dump -h localhost -U postgres(
用户名) 数据库名(缺省时同用户名) >/data/dum.sql 导出某个表 pg_dump -h localhost -U postgres(用户名) 数据库名(缺省时同用户名) -t table(表名) >/data/dum.sql
评论列表(0条)