简体   繁体   English

如何从 AWS Aurora 上的文件导入某些数据

[英]How to import certain data from file on AWS Aurora

Problem: I have an Aurora RDS database that has a table where the data for a certain column was deleted.问题:我有一个 Aurora RDS 数据库,它有一个表,其中特定列的数据已被删除。 I have a snapshot of the DB from a few days ago that I want to use to populate the said column with the values from the snapshot.我有几天前的数据库快照,我想用它来用快照中的值填充所述列。 The issue is that certain rows have been deleted from the live DB in the meantime and I don't want to include them again.问题是某些行已同时从活动数据库中删除,我不想再次包含它们。

I want to mount the snapshot, connect to it and then SELECT INTO OUTFILE S3 the table that interests me.我想挂载快照,连接到它,然后选择我感兴趣的表SELECT INTO OUTFILE S3 Then I will LOAD DATA FROM S3 into the live DB, selecting only the column that interests me.然后我将从LOAD DATA FROM S3到实时数据库中,只选择我感兴趣的列。 But I haven't found information about what happens if the number of rows differ, namely if the snapshot has rows that were deleted in the meantime from the live DB.但是我还没有找到有关如果行数不同会发生什么的信息,即快照是否有同时从实时数据库中删除的行。

Does the import command take the ID column into consideration when doing the import?导入命令在导入时是否考虑了 ID 列? Should I also import the ID column?我还应该导入 ID 列吗? I don't want to recreate the rows in question, I only want to populate the existing rows with the values from the column I want from the snapshot.我不想重新创建有问题的行,我只想用快照中我想要的列中的值填充现有行。

ALTER TABLE the destination table to add the column you are missing. ALTER TABLE目标表以添加您缺少的列。 It will be empty of data for now.现在它将没有数据。

LOAD DATA your export into a different table than the ultimate destination table. LOAD DATA您将导出到与最终目标表不同的表中。

Then do an UPDATE with a JOIN between the destination table and the imported table.然后在目标表和导入表之间使用JOIN执行UPDATE In this update, copy the values for the column you're trying to restore.在此更新中,复制您尝试恢复的列的值。

By using an inner join, it will only match rows that exist in both tables.通过使用内部联接,它只会匹配两个表中都存在的行。

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

相关问题 如何在 AWS CDK 项目/堆栈中导入现有的 Aurora MySQL 集群? - How to import an existing Aurora MySQL cluster in a AWS CDK project/stack? 使用 AWS Glue 将数据从 S3 加载到 Aurora Serverless - Load data from S3 into Aurora Serverless using AWS Glue 如何编写触发器以将数据从 aurora 插入到 redshift - how to write a Trigger to insert data from aurora to redshift CSV 使用 DataGrip 删除连接导入 AWS Aurora MySQL(5.6) - CSV import to AWS Aurora MySQL(5.6) with DataGrip dropping connection AWS Aurora MYSQL 如何处理不断增长的表 - AWS Aurora MYSQL how to deal with growing table 如何使用 prisma 连接 AWS aurora (posgresSQL) - How to connect AWS aurora (posgresSQL) using prisma MySQL Aurora 和 AWS S3:需要 MySQL 的“加载数据”的替代方法来从 S3 加载文档数据 - MySQL Aurora and AWS S3: Need an alternate way of MySQL's "LOAD DATA" for loading document data from S3 如何使用带有制表符分隔符的“aws_s3.query_export_to_s3”从 RDS/Aurora 导出到 S3? - How to export to S3 from RDS / Aurora using `aws_s3.query_export_to_s3` with a tab delimiter? 将数据从 Amazon Aurora 同步到 Redshift - Sync data from Amazon Aurora to Redshift 从 AWS Aurora Serverless v1 升级到 v2 失败 - Upgrading from AWS Aurora Serverless v1 to v2 fails
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM