如何从mysql数据库导出excel表? [英] How to export table to excel from mysql database?

查看:143
本文介绍了如何从mysql数据库导出excel表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在mysql中有一个表,这个表对于拥有超过10万行是相当大的,我想将其导出到excel。但是,我尝试导出到excel函数phpmyadmin,但它永远是转储excel文件。甚至没有倾销。错误始终是连接重置。有没有一个替代的方式如何做到这一点?

解决方案

首先,Excel中的100k行听起来像一个可怕的想法和当然这将需要一段时间。这将需要一段时间才能开放。如果你必须这样做:

  SELECT order_id,product_name,qty 
FROM orders
INTO OUTFILE'
FIELDS TERMINATED BY','
ENCLOSED BY'''
LINES TERMINATED BY'\\\
'

这应该给你一个名为: /tmp/orders.csv 的文件,它将在Excel中打开。


I have a table in mysql which is quite big for having over 100k rows and I want to export it to excel. However, I tried the export to excel function on phpmyadmin but it takes forever to dump the excel file. It's not even dumping. The error is always, "the connection is reset". Is there an alternative way on how to do this??

解决方案

First, 100k rows in Excel sounds like a horrible idea and of course it'll take awhile. This is going to take awhile just to open. If you MUST do this try:

SELECT order_id,product_name,qty
FROM orders
INTO OUTFILE '/tmp/orders.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'

This should give you a file called: /tmp/orders.csv which will open in Excel.

这篇关于如何从mysql数据库导出excel表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆