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中,如何为每个组选择前2行 2021-01-01
- 远程 mySQL 连接抛出“无法使用旧的不安全身份验证连接到 MySQL 4.1+"来自 XAMPP 的错误 2022-01-01
- 如何将 SonarQube 6.7 从 MySQL 迁移到 postgresql 2022-01-01
- 如何将 Byte[] 插入 SQL Server VARBINARY 列 2021-01-01
- 导入具有可变标题的 Excel 文件 2021-01-01
- SQL 临时表问题 2022-01-01
- 更改自动增量起始编号? 2021-01-01
- 以一个值为轴心,但将一行上的数据按另一行分组? 2022-01-01
- 如何使用 pip 安装 Python MySQLdb 模块? 2021-01-01
- 使用 Oracle PL/SQL developer 生成测试数据 2021-01-01