求postgreSQL 的数据库的表数据,导入导出的sql语句,谢谢!

发布网友

我来回答

2个回答

热心网友

Postgresql数据的导入和导出,以及copy命令介绍

如何导出PostgreSQL数据库中的数据:
pg_mp -U postgres -f mp.sql mydatabase
具体某个表
pg_mp -U postgres -t mytable -f mp.sql mydatabase

导入数据时首先创建数据库再用psql导入:
createdb newdatabase
psql -d newdatabase -U postgres -f mp.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_mp.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"

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com