Can I restore a single table from a full mysql mysqldump file?(我可以从完整的 mysql mysqldump 文件中恢复单个表吗?)
问题描述
我有我的 mysql 数据库的 mysqldump 备份,其中包含我们所有的表,大约 440 兆.我只想从 mysqldump 恢复其中一个表的内容.这可能吗?理论上,我可以剪掉重建我想要的表格的部分,但我什至不知道如何有效地编辑这么大的文本文档.
I have a mysqldump backup of my mysql database consisting of all of our tables which is about 440 megs. I want to restore the contents of just one of the tables from the mysqldump. Is this possible? Theoretically, I could just cut out the section that rebuilds the table I want but I don't even know how to effectively edit a text document that size.
推荐答案
你可以尝试使用 sed 来只提取你想要的表.
You can try to use sed in order to extract only the table you want.
假设您的表的名称是 mytable 而文件 mysql.dump 是包含您的巨大转储的文件:
Let say the name of your table is mytable and the file mysql.dump is the file containing your huge dump:
$ sed -n -e '/CREATE TABLE.*`mytable`/,/Table structure for table/p' mysql.dump > mytable.dump
这将在文件 mytable.dump 中复制位于 CREATE TABLE mytable 和对应于下一个表的下一个 CREATE TABLE 之间的内容.
This will copy in the file mytable.dump what is located between CREATE TABLE mytable and the next CREATE TABLE corresponding to the next table.
然后您可以调整文件mytable.dump,其中包含表mytable 的结构和数据(INSERT 的列表)).
You can then adjust the file mytable.dump which contains the structure of the table mytable, and the data (a list of INSERT).
这篇关于我可以从完整的 mysql mysqldump 文件中恢复单个表吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:我可以从完整的 mysql mysqldump 文件中恢复单个表吗?
基础教程推荐
- SQL:使用来自具有相同列名的两个表中的数据... 2021-01-01
- 需要 MySQL 5.1 中的抽象触发器来更新审计日志 2021-01-01
- SQL Server 实例在登录协商期间返回无效或不受支持的协议版本 2021-01-01
- SQL 效率:WHERE IN 子查询 vs. JOIN 然后 GROUP 2021-01-01
- SSMS 中的权限问题:“对象 'extended_properties'、数据库 'mssqlsystem_resource'、... 错误 229)上的 SELECT 权限被拒绝" 2022-01-01
- 将 SQL Server DateTime 列迁移到 DateTimeOffset 2021-01-01
- 无法解决整理冲突 2021-01-01
- 在 SQL 中连接多个表 2021-01-01
- 如何使用 mysql.connector 禁用查询缓存 2022-01-01
- 是否可以执行按位分组功能? 2021-01-01
