{"id":13,"date":"2025-04-28T00:06:50","date_gmt":"2025-04-27T16:06:50","guid":{"rendered":"https:\/\/lib.kimsor.top\/?p=13"},"modified":"2025-05-26T17:52:12","modified_gmt":"2025-05-26T09:52:12","slug":"ces","status":"publish","type":"post","link":"https:\/\/lib.kimsor.top\/?p=13","title":{"rendered":"Mysql\u521d\u6b21select\u67e5\u8be2\u751f\u6210\u5feb\u7167\u5bfc\u81f4\u91cd\u590d\u63d2\u5165\u6848\u4f8b"},"content":{"rendered":"\n<p><\/p>\n\n\n\n<p>\u5f53\u524d\u6709\u4e00\u4e2a\u573a\u666f\uff1a<\/p>\n\n\n\n<p>\u9996\u5148\u67e5\u8be2\u8ba2\u5355\u8868\u662f\u5426\u6709\u8ba2\u5355\uff0c\u5982\u679c\u6709\u8ba2\u5355\u7684\u60c5\u51b5\u4e0b\u5219\u67e5\u8be2\u8bb0\u5f55\u8868\u662f\u5426\u5df2\u7ecf\u63d2\u5165\u8bb0\u5f55\uff0c\u5982\u679c\u6ca1\u6709\u5219\u8fdb\u884c\u63d2\u5165\u64cd\u4f5c<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>1\u3001\u5f00\u542f\u4e8b\u52a1A\uff0c\u5f00\u542f\u4e8b\u52a1B<\/strong><\/p>\n\n\n\n<p>\u4e8b\u52a1A\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>begin<\/code><\/pre>\n\n\n\n<p>\u4e8b\u52a1B\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>begin<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>2\u3001\u4e8b\u52a1A\u67e5\u8be2order\u8868\u662f\u5426\u6709id\u4e3a1\u7684\u8ba2\u5355\uff0c\u4e8b\u52a1B\u4e5f\u540c\u65f6\u67e5\u8be2order\u8868\u662f\u5426\u4e3aid\u4e3a1\u7684\u8ba2\u5355\uff08\u56e0\u4e3a\u6a21\u62df\u7684\u662f\u5e76\u53d1\uff0c\u6240\u4ee5\u8fd9\u91cc\u540c\u65f6\u8fdb\u884c\uff09<\/strong><\/p>\n\n\n\n<p>\u4e8b\u52a1A\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>select id from order where id = 1<\/code><\/pre>\n\n\n\n<p>\u4e8b\u52a1B\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>select id from order where id = 1<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>3\u3001\u4e8b\u52a1A\u548c\u4e8b\u52a1B\u67e5\u8be2\u5230\u6709\u8ba2\u5355\u540e\uff0c\u540c\u65f6\u8fdb\u884cfor update\u67e5\u8be2\uff0c\u6b64\u65f6A\u4e8b\u52a1\u5148\u6267\u884c\uff0cB\u4e8b\u52a1\u88ab\u963b\u585e<\/strong><\/p>\n\n\n\n<p>\u4e8b\u52a1A\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>select id from order where id = 1 for update<\/code><\/pre>\n\n\n\n<p>\u4e8b\u52a1B\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>select id from order where id = 1 for update<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>4\u3001A\u4e8b\u52a1\u83b7\u53d6\u5230\u9501\u4e4b\u540e\u67e5\u8be2\u8bb0\u5f55\u8868view\uff0c\u67e5\u8be2\u65e0\u6570\u636e\uff0c\u4e8b\u52a1B\u8fd8\u5728\u963b\u585e<\/strong><\/p>\n\n\n\n<p>\u4e8b\u52a1A\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>select * from view<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>5\u3001A\u4e8b\u52a1\u67e5\u8be2\u6709\u6570\u636e\u4e4b\u540e\u63d2\u5165\u8bb0\u5f55\u5230\u8bb0\u5f55\u8868\u4e2d\uff0cB\u4e8b\u52a1\u8fd8\u5728\u963b\u585e<\/strong><\/p>\n\n\n\n<p>\u4e8b\u52a1A\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>insert into view(val) values(100)<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>6\u3001A\u4e8b\u52a1\u6267\u884c\u5b8c\u6bd5\uff0c\u63d0\u4ea4\u4e8b\u52a1\u3002B\u4e8b\u52a1\u83b7\u5f97\u9501\uff0cB\u4e8b\u52a1\u6267\u884c\u5b8c\u4e0a\u9762\u7b2c3\u6761\u7684\u67e5\u8be2sql\u4e4b\u540e\uff0c\u4e5f\u8fdb\u884c\u67e5\u8be2\u8bb0\u5f55\u8868view\uff0c\u4f46\u662f\u53d1\u73b0\u4e5f\u6ca1\u6709\u6570\u636e<\/strong><\/p>\n\n\n\n<p>\u4e8b\u52a1B\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>select * from view<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>7\u3001B\u4e8b\u52a1\u67e5\u8be2view\u6ca1\u6709\u6570\u636e\u4e4b\u540e\u4e5f\u63d2\u5165\u4e86\u4e00\u6761\u8bb0\u5f55\u5230\u8bb0\u5f55\u8868<\/strong><\/p>\n\n\n\n<p>\u4e8b\u52a1B\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>insert into view(val) values(100)<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>8\u3001\u6700\u540eB\u4e8b\u52a1\u63d0\u4ea4\u4e8b\u52a1\uff0c\u6574\u4e2a\u8fc7\u7a0b\u7ed3\u675f<\/strong><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>\u6211\u4eec\u770b\u5230\u8fd9\u6709\u4e00\u4e2a\u7591\u95ee\uff0c\u4e3a\u4ec0\u4e48\u4e8b\u52a1A\u660e\u660e\u63d2\u5165\u4e86\u4e00\u6761\u8bb0\u5f55\uff0c\u4e3a\u4ec0\u4e48\u4e8b\u52a1B\u67e5\u8be2\u5e76\u6ca1\u6709\u8fd9\u6761\u8bb0\u5f55\uff0c\u5c31\u5bfc\u81f4\u4e86B\u4e8b\u52a1\u4e5f\u63d2\u5165\u4e86\u4e00\u6761\u4e00\u6a21\u4e00\u6837\u7684\u8bb0\u5f55\uff1f\u5e76\u4e14B\u4e8b\u52a1\u662f\u5728A\u4e8b\u52a1\u63d0\u4ea4\u540e\u624d\u8fdb\u884c\u67e5\u8be2\uff0c\u4e5f\u6ca1\u6709\u8fd9\u6761\u8bb0\u5f55\uff0c\u8fd9\u662f\u4e3a\u4ec0\u4e48\u5462\uff1f<\/p>\n<\/blockquote>\n\n\n\n<p><\/p>\n\n\n\n<p>\u89e3\u91ca\uff1a\u56e0\u4e3a\u4e8b\u52a1A\u548c\u4e8b\u52a1B\u5728\u6267\u884c\u4e00\u5f00\u59cb\u90fd\u8fdb\u884c\u4e86\u4e00\u6b21\u67e5\u8be2\uff08select id from order where id = 1\uff09\uff0c\u4e5f\u5c31\u662f\u8fd9\u65f6\u751f\u6210\u4e86\u5feb\u7167\uff0c\u5bfc\u81f4\u540e\u9762\u867d\u7136\u8c03\u4e86\u4e00\u6b21\u542b\u6709forupdate\u5237\u65b0\u4e86\u5feb\u7167\uff0c\u4f46\u662f\u5237\u65b0\u7684\u662forder\u8868\u7684\u5feb\u7167\uff0c\u5e76\u6ca1\u6709\u5237\u65b0view\u8868\u7684\u5feb\u7167\uff0c\u6240\u4ee5\u5bfc\u81f4\u4e3a\u4ec0\u4e48\u4e8b\u52a1A\u5df2\u7ecf\u63d2\u5165\u4e86\u4e00\u6761\u8bb0\u5f55\u5e76\u63d0\u4ea4\u4e86\u4e8b\u52a1\uff0c\u4f46\u662f\u4e8b\u52a1B\u5374\u6ca1\u6709\u67e5\u8be2\u5230\u8bb0\u5f55\u5e76\u91cd\u590d\u63d2\u5165\u4e86\u8bb0\u5f55<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5f53\u524d\u6709\u4e00\u4e2a\u573a\u666f\uff1a \u9996\u5148\u67e5\u8be2\u8ba2\u5355\u8868\u662f\u5426\u6709\u8ba2\u5355\uff0c\u5982\u679c\u6709\u8ba2\u5355\u7684\u60c5\u51b5\u4e0b\u5219\u67e5\u8be2\u8bb0\u5f55\u8868\u662f\u5426\u5df2\u7ecf\u63d2\u5165\u8bb0\u5f55\uff0c\u5982\u679c\u6ca1\u6709\u5219\u8fdb\u884c\u63d2\u5165 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,3],"tags":[],"class_list":["post-13","post","type-post","status-publish","format-standard","hentry","category-mysql","category-database"],"_links":{"self":[{"href":"https:\/\/lib.kimsor.top\/index.php?rest_route=\/wp\/v2\/posts\/13","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lib.kimsor.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lib.kimsor.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lib.kimsor.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lib.kimsor.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=13"}],"version-history":[{"count":7,"href":"https:\/\/lib.kimsor.top\/index.php?rest_route=\/wp\/v2\/posts\/13\/revisions"}],"predecessor-version":[{"id":147,"href":"https:\/\/lib.kimsor.top\/index.php?rest_route=\/wp\/v2\/posts\/13\/revisions\/147"}],"wp:attachment":[{"href":"https:\/\/lib.kimsor.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=13"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lib.kimsor.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=13"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lib.kimsor.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=13"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}