MySQL 使用 phpmyadmin 将表结构导出到 Excel 文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12399501/
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 14:49:15  来源:igfitidea点击:

exporting table structure to Excel files with phpmyadmin

mysqlphpmyadmin

提问by hamedkh

I' going to create an excel file from my table structure in Phpmyadmin(structure only).I found that it has a CSV output but it gives me just data.
Does Phpmyadmin has any feature to do such a thing or not?

我将在 Phpmyadmin(仅结构)中从我的表结构创建一个 excel 文件。我发现它有一个 CSV 输出,但它只给我数据。
phpmyadmin 是否有任何功能可以做这样的事情?

Edit: it's my sql :

编辑:这是我的 sql :

SELECT * INTO OUTFILE 'c://wamp/my_table_structure.csv'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES  TERMINATED BY '\n'
FROM   INFORMATION_SCHEMA.COLUMNS
WHERE  TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'dt_user'

why it return an empty file?

为什么它返回一个空文件?

回答by eggyal

You could run a SELECT ... INTO OUTFILEquery along the following lines:

您可以SELECT ... INTO OUTFILE按照以下几行运行查询:

SELECT * INTO OUTFILE '/path/to/my_table_structure.csv'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES  TERMINATED BY '\n'
FROM   INFORMATION_SCHEMA.COLUMNS
WHERE  TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'my_table'

回答by Eswar Rajesh Pinapala

I had the same problem and I achieved with the combination of PHPMyadmin and a chrome plugin. This might not be the straightforward way but it just works. (Assuming you are using Google Chrome)

我遇到了同样的问题,我通过 PHPMyadmin 和 chrome 插件的组合实现了。这可能不是直接的方法,但它确实有效。(假设您使用的是 Google Chrome)

enter image description here

在此处输入图片说明

  • once the print view opens in a new tab, click on the plugin icon in the address bar,
  • 在新选项卡中打开打印视图后,单击地址栏中的插件图标,

enter image description here

在此处输入图片说明

  • Click on the plugin icon and you will be shown options to either copy table to clipboard or export to Google docs.
  • 单击插件图标,您将看到将表格复制到剪贴板或导出到 Google 文档的选项。

enter image description here

在此处输入图片说明

  • I did a copy and pasted the table into excel. You can also export to google docs.
  • 我做了一个复制并将表格粘贴到excel中。您还可以导出到谷歌文档。

enter image description here

在此处输入图片说明

Note: This is just a workaround and just wanted to share this. Please be easy on comments & TD's :) , and I like the way proposed by eggyal anyways!

注意:这只是一种解决方法,只是想分享一下。请对评论和 TD 放轻松 :) ,无论如何我喜欢eggyal 提出的方式!

回答by user3302970

You don't need a plugin to copy and paste to Excel.

您不需要插件来复制和粘贴到 Excel。

  1. In phpmyadmin select the table you want to export the schema from
  2. Click on Print View at the bottom of the page
  3. Select the entire (or partial) table and click ctrl-c to copy
  4. Open a new Excel worksheet and select the first cell
  5. Click ctrl-v to paste
  1. 在 phpmyadmin 中选择要从中导出架构的表
  2. 单击页面底部的打印视图
  3. 选择整个(或部分)表格并点击 ctrl-c 复制
  4. 打开一个新的 Excel 工作表并选择第一个单元格
  5. 点击 ctrl-v 粘贴

回答by jmacboy

Nowadays, phpmyadmin has an export format called CSV for Microsoft Excel, which makes it all automatically, you just need to click export on a table view and choose the format.

现在,phpmyadmin 有一个名为 CSV for Microsoft Excel 的导出格式,它可以自动完成,您只需要在表视图上单击导出并选择格式。

回答by alfmonc

In phpMyAdmin find your table and then select the Export tab In your table select tab Export

在 phpMyAdmin 中找到您的表格,然后选择“导出”选项卡 在您的表中选择选项卡导出

Select Format CSV for MS Ecel Select Format CSV for MS Excel

为 MS Ecel 选择 CSV 格式 为 MS Excel 选择 CSV 格式

Just open a new Excel file, then click Data tab and then From Text/CSV and find the file you created in phpMyAdmin.Then click Load. Excel will create the columns just like the table in your data base, you can modify the delimiters if needed. Select tab Data and then From Text/CSV and then find your csv file

只需打开一个新的 Excel 文件,然后单击数据选项卡,然后单击来自文本/CSV 并找到您在 phpMyAdmin 中创建的文件。然后单击加载。Excel 会像数据库中的表格一样创建列,您可以根据需要修改分隔符。 选择选项卡数据,然后从文本/CSV,然后找到您的 csv 文件