简体   繁体   English

将记录从一个数据库实例移动到另一个数据库实例

[英]Moving records from one database instance to another

I have a PostgreSQL database instance located in EU region.我有一个位于欧盟地区的 PostgreSQL 数据库实例。 I plan on introducing another PostgreSQL database instance located in a new geographical region.我计划引入另一个位于新地理区域的 PostgreSQL 数据库实例。

As part this work, I am to migrate data for selected customers from a database instance in EU to a database instance in this new geo region and am seeking for advice.作为这项工作的一部分,我要将选定客户的数据从欧盟的数据库实例迁移到这个新地理区域的数据库实例,并寻求建议。

On a surface, this boils down to doing the following work:从表面上看,这归结为做以下工作:

  • given a specific accounts.id ,给定一个特定的accounts.id
  • find and copy the record from accounts table from EU database instance to accounts table in another region's database instance,从欧盟数据库实例的accounts表中查找记录并将其复制到另一个区域的数据库实例中的accounts表,
  • identify and copy records across all tables that are related to given account record, recursively (eg as well as potentially from tables related to those tables...).递归地识别和复制与给定account记录相关的所有表中的记录(例如,以及可能从与这些表相关的表中......)。

Effectively, having a specific DB record as starting point, I need to:实际上,以特定的数据库记录为起点,我需要:

  1. build a hierarchy, or rather a graph of DB records across all available tables, all directly (or indirectly) related to the "starting point" record (all possible relations, perhaps, could be established based on a foreign key constraints),建立一个层次结构,或者更确切地说是所有可用表的数据库记录图,所有表都直接(或间接)与“起点”记录相关(所有可能的关系,也许,可以基于外键约束建立),
  2. for each record found across all tables, generate a string containing an INSERT statement,对于在所有表中找到的每条记录,生成一个包含INSERT语句的字符串,
  3. replay all INSERT statements, in a transaction, on another database instance.在另一个数据库实例上重播事务中的所有INSERT语句。

It appears as if I might need to build a tool to do this kind of work.看来我可能需要构建一个工具来完成此类工作。 But before I do, I wonder:但在我这样做之前,我想知道:

  • is there a common approach for implementing this?有没有一种通用的方法来实现这个? , ,
  • if not, what might be a good starting point to approach this problem?如果不是,什么可能是解决这个问题的一个好的起点?

Indeed You need a whole proccess yo do this, i think that You should create a new schema to do the data Select i think functions could do the magic, then replicate that data.事实上,你需要一个完整的过程来做这件事,我认为你应该创建一个新的模式来处理数据 Select 我认为函数可以发挥魔力,然后复制该数据。

They replication tool it's not that hard to configurate.他们的复制工具配置起来并不难。

Here it's the link: https://www.postgresql.org/docs/current/runtime-config-replication.html !这是链接: https://www.postgresql.org/docs/current/runtime-config-replication.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Django将对象从一个数据库移动到另一个数据库 - Django Moving an object from one database to another django,postgresql:将转储的数据库数据从一台机器移动到另一台机器 - django, postgresql: moving dumped database data from one machine to another Postgres 9.4:仅将一个数据库从一个实例复制到另一个实例 - Postgres 9.4: Replicate only one database from one instance to another 如何通过来自另一个表但不同类型的多个连接记录来过滤数据库表? - How to filter database table by a multiple join records from another one table but different types? 将记录从一个表插入到另一个表,然后删除插入的记录 - Insert records from one table to another and then delete inserted records 从另一个数据库插入一个数据库? - Insert into one database from another database? 从一个表中获取重复项以获取另一个表中的记录 - Get duplicates from one table for records from another SQL:使用CASE将一个表中的记录与另一个表中的记录连接起来 - SQL: Join records in one table with count from another using CASE PSQL查询根据条件将记录从一张表插入到另一张表 - PSQL query to insert the records from one table to another based on condition 使用另一张表中的键将记录插入到一张表中 - Insert records into one table using key from another table
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM