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.
分享到:
相关推荐
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 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 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 ...
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 ...
微软企业库EnterpriseLibrary连接PostgreSQL时所需库文件,需要注意微软企业库(Microsoft.Practices.EnterpriseLibrary.Data和Microsoft.Practices.EnterpriseLibrary.Common)版本需要是4.1.0才行,同时需要Npgsql...
PostgreSQL for Data Architects 英文epub 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn删除
Data Export for PostgreSQL 试用版 试用版 开发语言: 软件 可用平台: Windows 当前版本: v3.7 EMS Data Export for PostgreSQL是一款交叉平台(Windows:registered: 和 Linux)的数据库工具,它可以快速得将您的...
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 ...
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 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 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....
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 ...
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 ...
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介绍与概念》由Bruce Momjian撰写,是一本深入探讨PostgreSQL数据库管理系统的核心原理、功能特性和管理技巧的专业书籍。此书不仅适合初学者了解PostgreSQL的基础知识,也适用于经验丰富的数据库管理员...