MYSQL Dump only certain rows

亡梦爱人 提交于 2019-11-27 09:49:31

问题


I am trying to do a mysql dump of a few rows in my database. I can then use the dump to upload those few rows into another database. The code I have is working, but it dumps everything. How can I get mysqldump to only dump certain rows of a table?

Here is my code:


mysqldump --opt --user=username --password=password lmhprogram myResumes  --where=date_pulled='2011-05-23' > test.sql


回答1:


Just fix your --where option. It should be a valid SQL WHERE clause, like:

--where="date_pulled='2011-05-23'"

You have the column name outside of the quotes.




回答2:


You need to quote the "where" clause.

Try

mysqldump --opt --user=username --password=password lmhprogram myResumes  --where="date_pulled='2011-05-23'" > test.sql



回答3:


Use this code for specific table rows, using LIKE condition.

mysqldump -u root -p sel_db_server case_today --where="date_created LIKE '%2018
%'" > few_rows_dump.sql


来源:https://stackoverflow.com/questions/6113213/mysql-dump-only-certain-rows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!