MySQL: Create Dump From Select Query

Posted on 2011-09-16
Last Modified: 2012-05-12
I want to create a SQL dump that I can use to manually import the selected records to another database.

How can this query be modified to create SQL text that could be used for the dump?
select * from elqBooks WHERE `isbn` like '9780813343310'

Open in new window

Question by:hankknight
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 12

Expert Comment

ID: 36550741
goto "view" menu and select view as text instead of view as grid.

You'll get the output as text...
LVL 16

Author Comment

ID: 36550765
This is a MySQL question.  I use MySQL from a command line.  There is no menu view.
LVL 78

Assisted Solution

arnold earned 150 total points
ID: 36550795

Excerpt from the link
SELECT order_id,product_name,qty
FROM orders
INTO OUTFILE '/tmp/orders.csv'

Open in new window

Is Your DevOps Pipeline Leaking?

Is your CI/CD pipeline a hodge-podge of randomly connected tools? You’ve likely got a tool to fix one problem & then a different tool to fix another, resulting in a cluster of tools with overlapping functionality. Learn how to optimize your pipeline with Gartner's recommendations

LVL 16

Author Comment

ID: 36550847
Can I do this without manually defining the columns, and can the output be SQL instead of CSV?
LVL 78

Expert Comment

ID: 36550958
Can you explain what you mean by SQL?

select * from elqBooks WHERE `isbn` like '9780813343310'
INTO OUTFILE '/tmp/elqbooks.txt'

This will likely be a tab separated data (tsv) data format.
Do you need it to have | as separator (fields terminated by '|')

LVL 25

Accepted Solution

Tomas Helgi Johannsson earned 350 total points
ID: 36551721

If you want to extract particular data from a table into a file which has the data surrounded by INSERT statement then you
use the mysqldump program with the where option
See the manual :)

So this command for you would be something like this
mysqldump -t -u [username] -p test elqBooks --where="isbn` like '9780813343310'"
see more examples here

Hope this helps.
    Tomas Helgi

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is intended for those who are new to PHP error handling (  It addresses one of the most common problems that plague beginning PHP develop…
In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor ( Top Charts is a view in which you can set seve…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question