Wednesday 18 July 2018

How to Export the results of a Query using MySQL Workbench

How to Export the results of a Query using MySQL Workbench


You can use MySQL Workbench to run a query, then export the results of that query to a file.
To do this:
  1. Run the query
  2. Click Export on the Results Grid menu bar
Here’s a screenshot:
Screenshot of the Result Grid with the Export option highlighted.
Clicking the Export button on the Result Grid toolbar allows you to export the query results to a file.
Important: MySQL Workbench limits the result set to 1000 rows by default. Be sure to remove this limitation if you don’t want your result set to be limited to that amount (or some other amount if it has been specified).
You can change that setting by clicking the Limit to 1000 rows dropdown and selecting Don't Limit.

File Formats

You have a choice of file formats to save the file in. Here are the formats supported at the time of writing:
  • CSV
  • CSV (; separated)
  • HTML
  • JSON
  • SQL INSERT statements
  • Excel Spreadsheet
  • XML
  • XML (MySQL format)
  • Tab separated

The Query Menu

You can also initiate the export via the MySQL Workbench Query menu:
Screenshot of the Export Results option of the Query menu.
The Query menu also provides an “Export Results…” option.
You can also use the SELECT ... INTO OUTFILE statement to export the query results from within the query. This exports the file as soon as the query runs.

0 comments:

Post a Comment