I want to dump single record from mysql table named as table1 for id = 5.
What is mysql query for same?
I think we can use mysqldump
but i have used it with full records of table. But how to use it with single record?
SELECT a single row from the source instance, save it in a variable in the script. Then form an INSERT command to execute against the destination instance. This may not be the most efficient way to move a large amount of data, but for a single row it would be fine.
On the Object Select > Tables to Export tab, select the sakila schema. 3. Under Export Options, select Export to Dump Project Folder if you want database tables to be stored to separate . sql files or Export to Self-Contained File to store the database dump in a single .
Mysqldump with Transactions The --single-transaction flag will start a transaction before running. Rather than lock the entire database, this will let mysqldump read the database in the current state at the time of the transaction, making for a consistent data dump.
Mysqldump is a command-line utility that is used to generate the logical backup of the MySQL database. It produces the SQL Statements that can be used to recreate the database objects and data. The command can also be used to generate the output in the XML, delimited text, or CSV format.
if you check at http://dev.mysql.com/doc/refman/5.0/en/mysqldump.html you will find --where option which is the one you need.
Below follows what is stated in that reference:
--where='where_condition', -w 'where_condition'
Dump only rows selected by the given WHERE condition. Quotes around the condition are mandatory if it contains spaces or other characters that are special to your command interpreter.
Examples:
--where="user='jimf'"
-w"userid>1"
-w"userid<1"
I just would like to post a more explicit answer. This is complementary to the accepted one.
mysqldump -uremote_user -premote_password -hdatabase_host remote_database_name remote_table_name --where='id=1234' --skip-add-drop-table --no-create-info
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With