PostgreSQL如何导入数据

来源:百度知道 编辑:UC知道 时间:2024/06/21 19:50:37
谁知道windows下的PostgreSQL数据库文件如何导入到linux的PostgreSQL下?

windows下
运行pg_dumpall > outfile

linux下
psql -f outfile postgres

如果是在两台不同的计算机上,虚拟机当然也算,同时启动两台电脑的postgres服务

可以
pg_dump -h host1 dbname | psql -h host2 dbname

如果数据库比较简单,建议直接在新的数据库中,新建表等逻辑结构,在通过旧的数据库中运行copy table to file with csv
新的数据库中运行copy table from file with csv导入数据

其他方式和具体情况可以看文档http://www.postgresql.org/docs/8.3/interactive/backup.html