{"id":35763,"date":"2024-11-26T15:38:45","date_gmt":"2024-11-26T07:38:45","guid":{"rendered":"https:\/\/fwq.ai\/blog\/35763\/"},"modified":"2024-11-26T15:38:45","modified_gmt":"2024-11-26T07:38:45","slug":"%e6%89%b9%e9%87%8f%e6%8f%92%e5%85%a5%e6%95%b0%e6%8d%ae%e6%97%b6%e5%a6%82%e4%bd%95%e5%a4%84%e7%90%86%e9%94%99%e8%af%af%e8%ae%b0%e5%bd%95%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/35763\/","title":{"rendered":"\u6279\u91cf\u63d2\u5165\u6570\u636e\u65f6\u5982\u4f55\u5904\u7406\u9519\u8bef\u8bb0\u5f55\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173072365334508.jpg\" class=\"aligncenter\" title=\"\u6279\u91cf\u63d2\u5165\u6570\u636e\u65f6\u5982\u4f55\u5904\u7406\u9519\u8bef\u8bb0\u5f55\uff1f\u63d2\u56fe\" alt=\"\u6279\u91cf\u63d2\u5165\u6570\u636e\u65f6\u5982\u4f55\u5904\u7406\u9519\u8bef\u8bb0\u5f55\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u6279\u91cf\u63d2\u5165\u4e2d\u5904\u7406\u9519\u8bef\u8bb0\u5f55<\/strong><\/p>\n<p>\u5728\u6279\u91cf\u63d2\u5165\u64cd\u4f5c\u4e2d\uff0c\u6709\u65f6\u53ef\u80fd\u51fa\u73b0\u5176\u4e2d\u4e00\u6761\u6216\u591a\u6761\u8bb0\u5f55\u63d2\u5165\u5931\u8d25\u7684\u60c5\u51b5\u3002\u4e3a\u4e86\u907f\u514d\u6574\u4e2a\u6279\u91cf\u64cd\u4f5c\u5931\u8d25\u56de\u6eda\uff0c\u6211\u4eec\u53ef\u4ee5\u8003\u8651\u4f7f\u7528\u4ee5\u4e0b\u65b9\u6cd5\uff1a<\/p>\n<p><strong>\u4f7f\u7528 insert ignore \u8bed\u53e5<\/strong><\/p>\n<p>\u5728 insert \u8bed\u53e5\u4e2d\u6dfb\u52a0 ignore \u5173\u952e\u5b57\uff0c\u53ef\u4ee5\u5ffd\u7565\u56e0\u4e3b\u952e\u91cd\u590d\u6216\u5176\u4ed6\u8fdd\u53cd\u552f\u4e00\u6027\u7ea6\u675f\u800c\u5bfc\u81f4\u7684\u9519\u8bef\u3002\u8fd9\u6837\uff0c\u5f53\u51fa\u73b0\u9519\u8bef\u8bb0\u5f55\u65f6\uff0c\u540e\u7eed\u8bb0\u5f55\u4ecd\u80fd\u6b63\u5e38\u63d2\u5165\u3002<\/p>\n<p>\u793a\u4f8b\uff1a<\/p>\n<pre>&lt;insert id=\"addUser\" parameterType=\"java.util.List\"&gt;\n    insert ignore into user(name,age) values\n    &lt;foreach collection=\"list\" item=\"item\" index=\"index\" separator=\",\"&gt;\n        (#{item.name},#{item.age})\n    &lt;\/foreach&gt;\n&lt;\/insert&gt;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u6279\u91cf\u63d2\u5165\u6570\u636e\u65f6\u5982\u4f55\u5904\u7406\u9519\u8bef\u8bb0\u5f55\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6279\u91cf\u63d2\u5165\u4e2d\u5904\u7406\u9519\u8bef\u8bb0\u5f55 \u5728\u6279\u91cf\u63d2\u5165\u64cd\u4f5c\u4e2d\uff0c\u6709\u65f6\u53ef\u80fd\u51fa\u73b0\u5176\u4e2d\u4e00\u6761\u6216\u591a\u6761\u8bb0\u5f55\u63d2\u5165\u5931\u8d25\u7684\u60c5\u51b5\u3002\u4e3a\u4e86\u907f\u514d\u6574\u4e2a\u6279\u91cf\u64cd\u4f5c\u5931\u8d25\u56de\u6eda\uff0c\u6211\u4eec\u53ef\u4ee5\u8003\u8651\u4f7f\u7528\u4ee5\u4e0b\u65b9\u6cd5\uff1a \u4f7f\u7528 insert ignore \u8bed\u53e5 \u5728 insert \u8bed\u53e5\u4e2d\u6dfb\u52a0 ignore \u5173\u952e\u5b57\uff0c\u53ef\u4ee5\u5ffd\u7565\u56e0\u4e3b\u952e\u91cd\u590d\u6216\u5176\u4ed6\u8fdd\u53cd\u552f\u4e00\u6027\u7ea6\u675f\u800c\u5bfc\u81f4\u7684\u9519\u8bef\u3002\u8fd9\u6837\uff0c\u5f53\u51fa\u73b0\u9519\u8bef\u8bb0\u5f55\u65f6\uff0c\u540e\u7eed\u8bb0\u5f55\u4ecd\u80fd\u6b63\u5e38\u63d2\u5165\u3002 \u793a\u4f8b\uff1a &lt;insert id=&#8221;addUser&#8221; parameterType=&#8221;java.util.List&#8221;&gt; insert ignore into user(name,age) values &lt;foreach collection=&#8221;list&#8221; item=&#8221;item&#8221; index=&#8221;index&#8221; separator=&#8221;,&#8221;&gt; (#{item.name},#{item.age}) &lt;\/foreach&gt; &lt;\/insert&gt; \u767b\u5f55\u540e\u590d\u5236 \u4ee5\u4e0a\u5c31\u662f\u6279\u91cf\u63d2\u5165\u6570\u636e\u65f6\u5982\u4f55\u5904\u7406\u9519\u8bef\u8bb0\u5f55\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-35763","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/35763","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=35763"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/35763\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=35763"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=35763"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=35763"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}