`
high_java
  • 浏览: 12974 次
  • 性别: Icon_minigender_1
  • 来自: 成都
文章分类
社区版块
存档分类
最新评论

How to export data from postgresql and reload

阅读更多

Well, Recently I need to work on ubuntu and windows temporately. There are two postgresql servers that are running on ubuntu and windows respectively. But I need the data on both servers is consistent, so I need export the data then reload it after switching workstation. 

 

After doing some research, I found one build-in command in postgresql server does the tricks. pg_dump and pg_dumpall. Here I only use pg_dump to accomplish my task.

 

Export:

 

pg_dump -c scportal -h localhost -U ethanz > /home/ethanz/database_dump1.sql

 

 

-c
--clean
Output commands to clean (drop) database objects prior to outputting the commands for creating them. (Restore might generate some harmless errors.)

This option is only meaningful for the plain-text format. For the archive formats, you can specify the option when you call pg_restore.
 

That is exactly what I need, connect to my local server, export the sql.

 

Then I can put the exported sql to svn or wherever. After switching the workstation, I'm able to synchrnize the data from the output sql file

 

Load:

ethanz@ethanz-U:~$ psql -d scportal -h localhost -U ethanz -f /home/ethanz/database_dump1.sql

 Then postgresql will automatically drop the database, index, table, sequence and recreate them then load the data. I think it's a good solution to resynchronize small buntch of data. It's not suitable to huge database.

 

 

This article is only for reference.

 

分享到:
评论

相关推荐

    PostgreSQL.for.Data.Architects.1783288604

    The book covers PostgreSQL from a data architect's perspective – covering topics from installation from source to designing tables using SQL Power Architect, as well as deciding replication and ...

    PostgreSQL for Data Architects 原版PDF by Maymala

    PostgreSQL for Data Architects will teach you everything you need to learn in order to get a scalable and optimized PostgreSQL server up and running. The book starts with basic concepts (such as ...

    PostgreSQL for Data Architects(PACKT,2015)

    PostgreSQL for Data Architects will teach you everything you need to learn in order to get a scalable and optimized PostgreSQL server up and running. The book starts with basic concepts like ...

    PostgreSQL 11 Server Side Programming Quick Start Guide 1st Edition

    To build your capabilities further, you will learn how to write stored procedures, both functions and the new PostgreSQL 11 procedures, and create triggers to perform encapsulation and maintain data ...

    EntLibContrib.Data.PostgreSql.dll

    微软企业库EnterpriseLibrary连接PostgreSQL时所需库文件,需要注意微软企业库(Microsoft.Practices.EnterpriseLibrary.Data和Microsoft.Practices.EnterpriseLibrary.Common)版本需要是4.1.0才行,同时需要Npgsql...

    PostgreSQL for Data Architects epub

    PostgreSQL for Data Architects 英文epub 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn删除

    Data Export for PostgreSQL试用版:一款强大的PostgreSQL数据库数据导出软件

    Data Export for PostgreSQL 试用版 试用版 开发语言: 软件 可用平台: Windows 当前版本: v3.7 EMS Data Export for PostgreSQL是一款交叉平台(Windows:registered: 和 Linux)的数据库工具,它可以快速得将您的...

    Practical SQL: A Beginner's Guide to Storytelling with Data

    The book focuses on using SQL to find the story your data tells, with the popular open-source database PostgreSQL and the pgAdmin interface as its primary tools.You'll first cover the fundamentals of ...

    Learning PostgreSQL 10

    Learn client-side and server-side programming in PostgreSQL, and how to administer PostgreSQL databases Discover tips on implementing efficient database solutions with PostgreSQL 10 Who This Book ...

    PostgreSQL数据库内部原理剖析 PDF

    PostgreSQL query planner's internals How I Learned to Stop Worrying and Love the Planner.pdf PostgreSQL_Internals_1_for_PostgreSQL96_en_20170211-1.pdf Prestogres_Hacking_PostgreSQL_Internals_to_Solve_...

    dbExpress driver for PostgreSQL v3.2.3

    dbExpress is a database-independent layer that defines common interface to provide fast access to PostgreSQL from Delphi and C++Builder on Windows and Mac OS X for both 32-bit and 64-bit platforms....

    Practical SQL: A Beginner’s Guide to Storytelling with Data

    The book focuses on using SQL to find the story your data tells, with the popular open-source database PostgreSQL and the pgAdmin interface as its primary tools. You’ll first cover the fundamentals ...

    PostgreSQL Server Programming 2nd 原版PDF by Dar, Krosing, Mlodgenski & Roybal

    You will learn how to write functions and create your own data types, all in your favorite programming language. It is a step-by-step tutorial, with plenty of tips and tricks to kick-start server ...

    PostgreSQL Replication (英文版)

    Understand basic replication concepts and efficiently replicate PostgreSQL using high-end techniques to protect your data and run your server without interruptions Overview Explains the new ...

    Postgresql introduction and concepts

    《PostgreSQL介绍与概念》由Bruce Momjian撰写,是一本深入探讨PostgreSQL数据库管理系统的核心原理、功能特性和管理技巧的专业书籍。此书不仅适合初学者了解PostgreSQL的基础知识,也适用于经验丰富的数据库管理员...

Global site tag (gtag.js) - Google Analytics