MYSQL 只转储某些行

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6113213/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 20:00:08  来源:igfitidea点击:

MYSQL Dump only certain rows

mysqlsqlmysqldump

提问by Shattuck

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?

我正在尝试对我的数据库中的几行进行 mysql 转储。然后我可以使用转储将这几行上传到另一个数据库。我拥有的代码正在运行,但它会转储所有内容。如何让 mysqldump 只转储表的某些行?

Here is my code:

这是我的代码:


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

回答by AJ.

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

只需修复您的--where选择。它应该是一个有效的 SQL WHERE 子句,例如:

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

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

You have the column name outside of the quotes.

您在引号之外有列名。

回答by Neville Kuyt

You need to quote the "where" clause.

您需要引用“where”子句。

Try

尝试

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

回答by Rokonz Zaz

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

使用 LIKE 条件,将此代码用于特定的表行。

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