Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Export SQL table in CSV With Headers

I have a sql database in which i want to export some tables in CSV format. Users and purchases.

By using phpmyadmin, > Export function i've successfully exported all data in table but there are no headers (column title) in the excel sheet and its very confusing to determine data retrieved from that table.

its look like this:

enter image description here

And i need it like this: enter image description here

Any suggestion how to do this?

like image 597
user2997826 Avatar asked May 28 '14 20:05

user2997826


People also ask

How do I export a SQL query to a CSV file?

Next are the options (specific letters, each preceded by a dash) needed to export data from an SQL query to a CSV file. The first option is -S, followed by the name of the server, a backslash, the name of the SQL Server instance, a comma, and the port number for the connection.

How do I export a hive table to a CSV file?

If you wanted to export the Hive table into a CSV file (with comma delimiter fields), use the option ROW FORMAT DELIMITED FIELDS TERMINATED BY and specify the field delimiter you want. By default INSERT OVERWRITE DIRECTORY command exports result of the specified query into HDFS location.

How do I add column headers to a SQL Server query?

Here’s how to do it: Go to Tools > Options Navigate to Query Results > SQL Server > Results to Grid, then check “Include column headers when copying or saving the results” option: Click OK to save changes, close and restart SSMS to apply changes

Is there anyway to export data in mysql table with column headers?

3 Is there anyway to export data in MySQL table with column headers? I find a way to do this by hard-coding the headers into query but if there are about 60 or even 100 columns in a table then it is impossible.


2 Answers

This works for me. What version of phpmyadmin do you have?

  1. Under Browse, click on the table you want to export.
  2. At the bottom, in the Query results operations section, click on Export.
  3. In Export method, choose Custom.
  4. Change Format to CSV for MS Excel.
  5. Under Format-specific options, check Put columns names in the first row.
like image 89
S. Ahn Avatar answered Oct 24 '22 16:10

S. Ahn


  1. Click on the export button
  2. Export method custom
  3. Format CSV
  4. Format-specific options: Put columns names in the first row ( Select this checkbox)

enter image description here

like image 45
Jignesh Patel Avatar answered Oct 24 '22 15:10

Jignesh Patel