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
exporting table structure to Excel files with phpmyadmin
提问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 OUTFILE
query 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)
Install Table capture for chrome - https://chrome.google.com/webstore/detail/table-capture/iebpjdmgckacbodjpijphcplhebcmeop/related?hl=en
Once the plugin is installed, open PHPmyadmin > DB > table > click on Structure
Right cLick on Print View > open in a new tab( this is important as the chrome plugin doesn't work on tables in an iframe)
为 chrome 安装表格捕获 - https://chrome.google.com/webstore/detail/table-capture/iebpjdmgckacbodjpijphcplhebcmeop/related?hl=en
安装插件后,打开 PHPmyadmin > DB > table > 点击 Structure
右键单击“打印视图”> 在新选项卡中打开(这很重要,因为 chrome 插件不适用于 iframe 中的表格)
- once the print view opens in a new tab, click on the plugin icon in the address bar,
- 在新选项卡中打开打印视图后,单击地址栏中的插件图标,
- Click on the plugin icon and you will be shown options to either copy table to clipboard or export to Google docs.
- 单击插件图标,您将看到将表格复制到剪贴板或导出到 Google 文档的选项。
- I did a copy and pasted the table into excel. You can also export to google docs.
- 我做了一个复制并将表格粘贴到excel中。您还可以导出到谷歌文档。
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。
- In phpmyadmin select the table you want to export the schema from
- Click on Print View at the bottom of the page
- Select the entire (or partial) table and click ctrl-c to copy
- Open a new Excel worksheet and select the first cell
- Click ctrl-v to paste
- 在 phpmyadmin 中选择要从中导出架构的表
- 单击页面底部的打印视图
- 选择整个(或部分)表格并点击 ctrl-c 复制
- 打开一个新的 Excel 工作表并选择第一个单元格
- 点击 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
在 phpMyAdmin 中找到您的表格,然后选择“导出”选项卡
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.
只需打开一个新的 Excel 文件,然后单击数据选项卡,然后单击来自文本/CSV 并找到您在 phpMyAdmin 中创建的文件。然后单击加载。Excel 会像数据库中的表格一样创建列,您可以根据需要修改分隔符。