Postgresql数据的导入和导出,以及copy命令介绍
如何导出PostgreSQL数据库中的数据:
pg_dump -U postgres -f dump.sql mydatabase
具体某个表
pg_dump -U postgres -t mytable -f dump.sql mydatabase
导入数据时首先创建数据库再用psql导入:
createdb newdatabase
psql -d newdatabase -U postgres -f dump.sql
把数据按照自己所想的方式导出,强大的copy命令:
echo "copy students to? stdout DELIMITER '|'"|psql school|head
(students为表名,school为库名,各个字段以|分隔)
echo 'copy (select * from students order by age limit 10) to stdout;' | psql school
1, 导出esa数据库所有对象到esa.backup文件
pg_dump.exe --host localhost --port 5432 --username postgres --format custom --blobs --verbose --file "E:\Dl\esa.backup" esa
2, 导入esa.backup文件中esa数据库所有对象到esa数据库中
pg_restore.exe --host localhost --port 5432 --username postgres --dbname esa --verbose "E:\Dl\esa.backup"
用户登录
还没有账号?立即注册
用户注册
投稿取消
文章分类: |
|
还能输入300字
上传中....