{"id":125779,"date":"2020-06-27T03:19:16","date_gmt":"2020-06-26T19:19:16","guid":{"rendered":"http:\/\/4563.org\/?p=125779"},"modified":"2020-06-27T03:19:16","modified_gmt":"2020-06-26T19:19:16","slug":"%e4%b8%80%e4%b8%aa%e5%85%b3%e4%ba%8e-mysql-%e9%94%81%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=125779","title":{"rendered":"\u4e00\u4e2a\u5173\u4e8e mysql \u9501\u95ee\u9898"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u4e00\u4e2a\u5173\u4e8e mysql \u9501\u95ee\u9898               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : duanzs <\/span>  <span><i><\/i> 2<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u80cc\u666f\uff1a\u4e00\u4e2a\u5b9a\u65f6\u4efb\u52a1\uff08\u591a\u5b9e\u4f8b\uff09\uff0c\u53d6\u8868 A \u4e2d\u72b6\u6001\u4e3a\u201c\u521d\u59cb\u5316\u201d\u7684\u8bb0\u5f55\uff0c\u7136\u540e\u53d6\u8868 B \u4e2d\u5bf9\u5e94\u8bb0\u5f55\uff0cB \u5e93\u5b58-A \u6d88\u8d39\u5b58\u5728\u4e24\u79cd\u60c5\u51b5\u3002\u82e5 B-A=0\uff0cAB \u8bb0\u5f55\u90fd\u804c\u4f4d\u201c\u5b8c\u6210\u201d\u72b6\u6001\uff1b\u82e5 B-A&gt;0,AB \u8bb0\u5f55\u90fd\u804c\u4f4d\u201c\u5b8c\u6210\u201d\u72b6\u6001\u540e\uff0c\u518d\u751f\u6210\u4e00\u6761\u65b0\u7684 B \u8bb0\u5f55\uff0c\u5e93\u5b58\u5b57\u6bb5\u503c=B-A \uff1b<\/p>\n<p>\u6b63\u5e38\u60c5\u51b5\u4e00\uff1aAB \u5404\u4e00\u6761\u8bb0\u5f55\uff0c\u5e93\u5b58\u4e0e\u6d88\u8d39\u76f8\u7b49\uff0cAB \u5b8c\u6210\uff1b \u6b63\u5e38\u60c5\u51b5\u4e8c\uff1aAB \u5404\u4e00\u6761\u8bb0\u5f55\uff0c\u5e93\u5b58\u5927\u4e8e\u6d88\u8d39\uff0cAB \u5b8c\u6210\uff0c\u65b0\u751f\u6210\u4e00\u6761\u5e93\u5b58\u8bb0\u5f55 B \uff1b \u6b63\u5e38\u60c5\u51b5\u4e09\uff1a\u5e93\u5b58 B \u4e00\u6761\u8bb0\u5f55\uff0c\u503c\u4e3a 8\uff0c\u6d88\u8d39 A1 \u3001A2 \u4e24\u6761\u8bb0\u5f55\uff0c\u503c\u90fd\u4e3a 4 \u3002\u9996\u5148 A1 \u4e0e B \u8fdb\u884c\u64cd\u4f5c\uff0c8-4=4&gt;0,A1 \u548c B \u5b8c\u6210\uff0c\u7136\u540e\u751f\u6210\u4e00\u6761\u65b0 B\uff0c\u503c\u4e3a 4\uff0c\u7136\u540e A2 \u548c\u65b0 B \u64cd\u4f5c\u540e\u5168\u90e8\u5b8c\u6210\u3002<\/p>\n<p>\u5f02\u5e38\u60c5\u51b5\uff1a\u6839\u636e\u6b63\u5e38\u60c5\u51b5\u4e09\uff0cA1 \u4e0e A2 \u5148\u540e\u6267\u884c\u6ca1\u95ee\u9898\uff0c\u4f46\u662f\u56e0\u4e3a\u662f\u591a\u5b9e\u4f8b\uff0cA1 \u548c A2 \u53ef\u80fd\u540c\u65f6\u6267\u884c\uff0c\u540c\u65f6\u67e5\u8be2\u5230 B \u90a3\u4e00\u6761\u8bb0\u5f55\uff0c\u7136\u540e\u4fe9\u90fd 8-4=4&gt;0\uff0c\u6700\u540e\u751f\u6210\u4fe9\u65b0 B \u8bb0\u5f55<\/p>\n<p>\u7406\u60f3\u7ed3\u679c\uff1aB \u90a3\u6761\u8bb0\u5f55\u80fd\u4e0d\u80fd\u52a0\u4e2a\u9501\u6216\u5176\u5b83\u624b\u6bb5\u63a7\u5236\u4e00\u4e0b\uff08\u8868\u6570\u636e\u91cf\u5927\uff0c\u80af\u5b9a\u4e0d\u80fd\u9501\u6574\u4e2a\u8868\uff09\uff0c\u8ba9 A1 \u548c A2 \u5148\u540e\u987a\u5e8f\u6267\u884c\uff0c\u907f\u514d\u540c\u65f6\u6267\u884c<\/p>\n<p>\u6ce8\uff1a\u4e1a\u52a1\u6bd4\u8f83\u590d\u6742\uff0c\u5e76\u975e\u53ea\u662f\u5e93\u5b58-\u6d88\u8d39\u8005\u4e00\u4e2a\u5c0f\u903b\u8f91\uff0c\u6b64\u5904\u7b80\u5316\u95ee\u9898\u4e86<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>9<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"2162994\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : AngryPanda <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5185\u5b58\u9501\uff0clockName = B \u8868\u7684 ID                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2162995\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : AngryPanda <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e50\u89c2\u9501: UPDATE\/INSERT XXX WHERE B.quantity = 8                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2162996\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : AngryPanda <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u60b2\u89c2\u9501\uff1aselect xxx for update                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2162997\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : AngryPanda <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5176\u5b9e\u6211\u89c9\u5f97\u8bbe\u8ba1\u4e0a\u7a0d\u5fae\u6709\u70b9\u5947\u602a\u4e86\uff1aB &gt; A \u5e93\u5b58\u8868\u4e3a\u5565\u9700\u8981\u65b0\u751f\u6210\u8bb0\u5f55\u5462\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2162998\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : duanzs <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @AngryPanda \u8fd9\u53ea\u662f\u4e00\u4e2a\u7b80\u5316\u63cf\u8ff0\uff0c\u5176\u5b9e\u4e1a\u52a1\u4e0a\u8fdc\u6bd4\u63cf\u8ff0\u7684\u590d\u6742                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2162999\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : peyppicp <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u60f3\u987a\u5e8f\u5c31 3 \u60b2\u89c2\u9501\uff0cb \u8868\u91cc\u5982\u679c\u6709\u552f\u4e00\u7d22\u5f15\u7684\u8bdd\uff0cselect for update \u884c\u9501\u9501\u4f4f\uff0c\u7136\u540e\u518d\u505a\u4e1a\u52a1\u5c31\u884c\u4e86\uff0c\u5982\u679c\u6709\u5e76\u53d1\u4e5f\u4f1a\u5728\u8fd9\u884c\u9501\u8fd9\u91cc\u7b49\u5f85\u7684\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2163000\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : PopRain <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             update \u5e93\u5b58\u8868 set \u5e93\u5b58=4 where PK=xx and \u5e93\u5b58=8 \u80af\u5b9a\u6709\u4e00\u4e2a UPDATE \u4e0d\u6210\u529f\u7684\u3002\u3002\u3002\u3002 \uff08\u4e00\u822c\u5173\u952e\u7684\u66f4\u65b0\uff0c\u90fd\u8981\u52a0\u4e0a\u63a7\u5236\u5b57\u6bb5\uff08\u6216\u8005\u8bf4\u7248\u672c\u5b57\u6bb5\uff09\uff0c\u4f8b\u5b50\u4e2d\uff0c\u539f\u6765\u7684\u5e93\u5b58\u91cf\u5c31\u662f\u201c\u63a7\u5236\u5b57\u6bb5\u201d,\u80af\u5b9a\u8981\u4fdd\u8bc1\u66f4\u65b0\u7684\u662f\u4f60\u539f\u6765\u7684\u6570\u636e\uff0c\u8fd9\u4e2a\u90fd\u662f\u5f00\u53d1 ERP \u5e94\u7528\u7684\u5e38\u8bc6\u3002<\/p>\n<p>\u73b0\u5728\u5f88\u591a\u4eba\u90fd\u662f\u6839\u636e\u4e3b\u952e\u53bb UPDATE\uff0c\u5f53\u7136\u6709\u95ee\u9898\u4e86\uff08\u4f30\u8ba1\u662f\u67d0\u4e9b ORM \u81ea\u8eab\u7684\u9650\u5236\uff0c\u6216\u8005\u5bf9 ORM \u4e86\u89e3\u4e0d\u6df1\uff09                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2163001\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : crclz <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4f60\u8fd9\u4e2a\u662f\u6ca1\u6709\u4efb\u4f55\u95ee\u9898\u7684\u3002\u56e0\u4e3a\uff0c\u4f60\u4f1a\u5c06\u65e7\u7684 B \u7f6e\u4e3a\u201c\u5b8c\u6210\u201d\uff0c\u76f8\u5f53\u4e8e\u7ed9 B \u4e0a\u4e86\u4e00\u4e2a X \u9501\uff0c\u6240\u4ee5\u662f\u6ca1\u95ee\u9898\u7684\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2163002\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : crclz <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u540c\u65f6\uff0c\u5982\u679c\u4f60\u7684\u4e24\u4e2a\u4e8b\u52a1\u5bf9 B \u5148\u8bfb\u53d6\u7684\u65f6\u5019\u6ca1\u6709 FOR UPDATE\uff0c\u90a3\u4e48\u5b9e\u9645\u60c5\u51b5\u5c31\u4f1a\u6784\u6210\u6b7b\u9501\uff0c\u6216\u8005\u7b49\u5f85\u3002\u5f53\u7136\uff0c\u6b7b\u9501\u662f\u6ca1\u6709\u4efb\u4f55\u95ee\u9898\u7684\uff0c\u53ea\u4e0d\u8fc7\u4f1a\u727a\u7272\u4e00\u4e2a\u4e8b\u52a1\u3002\u6574\u4e2a\u6d41\u7a0b\u662f\u6ca1\u6709\u95ee\u9898\u7684\uff0c\u6211\u53ea\u662f\u89e3\u91ca\u4e00\u4e0b\u5185\u90e8\u8fd0\u884c\u8fc7\u7a0b\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u4e2a\u5173\u4e8e mysql \u9501\u95ee\u9898 \u8cc7\u6df1&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/125779"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=125779"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/125779\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=125779"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=125779"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=125779"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}