使用 MySQL Workbench 和 INSERT 语句导出表

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13255685/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 15:24:02  来源:igfitidea点击:

Export tables with MySQL Workbench with INSERT statements

mysqlmysql-workbench

提问by Alvaro

I am trying to export the DataBase i have at MySQL Workbench but I am having troubles to generate the INSERT statements on the .sql file.

我正在尝试导出我在 MySQL Workbench 上的数据库,但是在 .sql 文件上生成 INSERT 语句时遇到了麻烦。

I order to export the data, I do the reverse engineering for the database i want to export. Then, i go to

我为了导出数据,我对要导出的数据库进行逆向工程。然后,我去

File / Export/ Forward Engineer SQL CREATE Script

文件/导出/转发工程师 SQL CREATE 脚本

And once in there, i select the option Generate INSERT Statements for Tables.

在那里,我选择选项Generate INSERT Statements for Tables

The result only generates the code for the create tables.

结果只生成创建表的代码。

Is there any way to create the insert statements for the data?

有没有办法为数据创建插入语句?

Thanks

谢谢

回答by Vardan Gupta

For older versions:

对于旧版本:

Open MySQL Workbench > Home > Manage Import / Export (Right bottom) / Select Required DB > Advance Exports Options Tab >Complete Insert [Checked] > Start Export.

打开 MySQL Workbench > 主页 > 管理导入/导出(右下角)/选择所需的数据库 > 高级导出选项选项卡 > 完成插入 [选中] > 开始导出。



For 6.1 and beyond, thanks to ryandlf:

对于 6.1 及更高版本,感谢 ryandlf:

Click the management tab (beside schemas) and choose Data Export.

单击管理选项卡(模式旁边)并选择数据导出。

回答by Federico Piazza

I had some problems to find this option in newer versions, so for Mysql Workbench 6.3, go to schemas and enter in your connection:

在较新版本中找到此选项时遇到了一些问题,因此对于 Mysql Workbench 6.3,请转到 schemas 并输入您的连接:

enter image description here

在此处输入图片说明



Go to Tools -> Data Export

转到工具 -> 数据导出

enter image description here

在此处输入图片说明



Click on Advanced Options

点击高级选项

enter image description here

在此处输入图片说明



Scroll down and uncheck extended-inserts

向下滚动并取消选中 extended-inserts

enter image description here

在此处输入图片说明



Then export the data you want and you will see the result file as this:

然后导出您想要的数据,您将看到结果文件如下:

enter image description here

在此处输入图片说明

回答by solo

You can do it using mysqldump tool in command-line:

您可以在命令行中使用 mysqldump 工具执行此操作:

mysqldump your_database_name > script.sql

This creates a file with database create statements together with insert statements.

这将创建一个包含数据库创建语句和插入语句的文件。

More info about options for mysql dump: https://dev.mysql.com/doc/refman/5.7/en/mysqldump-sql-format.html

有关 mysql 转储选项的更多信息:https: //dev.mysql.com/doc/refman/5.7/en/mysqldump-sql-format.html

回答by kmas

In MySQL Workbench 6.1.

在 MySQL 中Workbench 6.1

I had to click on the Apply changesbutton in the insertion panel (only once, because twice and MWB crashes...).

我不得不点击Apply changes插入面板中的按钮(只有一次,因为两次 MWB 崩溃了......)。

You have to do it for each of your table.

你必须为你的每张桌子做这件事。

Apply changes button

应用更改按钮

Then export your schema :

然后导出您的架构:

Export schema

导出模式

Check Generate INSERT statements for table

查看 Generate INSERT statements for table

Check INSERT

检查插入

It is okay !

没关系 !

Inserts ok

插入正常

回答by Sunil

Go to Menu Server and Click on Data Export. There you can select the table and select the option Dump Structure and Data' from the drop-down.

转到菜单服务器并单击数据导出。在那里,您可以选择表格并从下拉列表中选择“转储结构和数据”选项。

回答by Riswan

For the latest version of MySql Workbench

对于最新版本的 MySql Workbench

  1. Click on the Server menu in the top menu bar
  2. Select 'Data Export' submenu
  3. It will open up the Object Selection window where you can select the appropriate database which has the desired tables
  4. Once you select the database in the left side all the tables will appear in the right side with radio buttons
  5. Select the radio buttons in front of needed tables
  6. Just below the table selection you can see a dropdown to select Dump Structure Only or Data only or Structure & Data
  7. Under Objects to Export tick the box if you need stored procedures or events also. If you don't need those then untick those
  8. Under export option change the exporting file name and path
  9. If you want to create the schema once you import the dump file then tick include create schema
  10. Press Start Export button in the right-hand side corner. once it successful the summary will be showing in the Export progress tab
  1. 单击顶部菜单栏中的服务器菜单
  2. 选择“数据导出”子菜单
  3. 它将打开对象选择窗口,您可以在其中选择具有所需表的适当数据库
  4. 在左侧选择数据库后,所有表格都将显示在右侧,并带有单选按钮
  5. 选择所需表格前面的单选按钮
  6. 在表选择的正下方,您可以看到一个下拉菜单,用于选择“仅转储结构”或“仅数据”或“结构和数据”
  7. 如果您还需要存储过程或事件,请在要导出的对象下勾选框。如果你不需要那些然后取消那些
  8. 在导出选项下更改导出文件名和路径
  9. 如果您想在导入转储文件后创建架构,请勾选包含创建架构
  10. 按右上角的开始导出按钮。一旦成功,摘要将显示在“导出进度”选项卡中