{"id":4339,"date":"2019-06-16T11:03:56","date_gmt":"2019-06-16T03:03:56","guid":{"rendered":"http:\/\/www.xttblog.com\/?p=4339"},"modified":"2019-06-16T11:03:56","modified_gmt":"2019-06-16T03:03:56","slug":"mysql-%e5%94%af%e4%b8%80%e7%b4%a2%e5%bc%95%e5%9c%a8-rr-%e5%92%8c-rc-%e9%9a%94%e7%a6%bb%e7%ba%a7%e5%88%ab%e4%b8%8b%e7%9a%84%e5%8a%a0%e9%94%81%e6%83%85%e5%86%b5%e6%80%bb%e7%bb%93","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=4339","title":{"rendered":"MySQL \u552f\u4e00\u7d22\u5f15\u5728 RR \u548c RC \u9694\u79bb\u7ea7\u522b\u4e0b\u7684\u52a0\u9501\u60c5\u51b5\u603b\u7ed3"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u4e0a\u4e00\u8bb2\uff0c\u6211\u7ed9\u5927\u5bb6\u89e3\u91ca\u4e86\uff0c\u4e3b\u952e\u7d22\u5f15 RR \u548c RC \u9694\u79bb\u7ea7\u522b\u4e0b\uff0c\u7cbe\u786e\u67e5\u8be2\uff08\u7b49\u503c\u67e5\u8be2\uff09\u3001\u8303\u56f4\u67e5\u8be2\u3001\u7a7a\u503c\u67e5\u8be2\u7684\u52a0\u9501\u60c5\u51b5\u3002\u8fd9\u4e00\u7bc7\uff0c\u6211\u5728\u7ed9\u5927\u5bb6\u603b\u7ed3\u4e00\u4e0b\u552f\u4e00\u7d22\u5f15\u5728 RR \u548c RC \u9694\u79bb\u7ea7\u522b\u4e0b\u7684\u52a0\u9501\u60c5\u51b5\u5427\uff01<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/wx1.sinaimg.cn\/large\/8fa5dcfcly1g42teh1jkij20gl080jwc.jpg\" alt=\"\" \/><figcaption>MySQL\u805a\u7c07\u7d22\u5f15\u7ed3\u6784\u56fe<\/figcaption><\/figure><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">\u8868\u8fd8\u662f\u4e0a\u4e00\u7bc7\u6587\u7ae0\u4e2d\u7684\u8868\uff0c\u53ea\u4e0d\u987e\u6211\u4eec\u9700\u8981\u5728 idcard \u5b57\u6bb5\u4e0a\u518d\u52a0\u4e0a\u552f\u4e00\u7d22\u5f15\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>CREATE TABLE `xttblog` (\n  `id` bigint(20) NOT NULL,\n  `name` varchar(16) COLLATE utf8mb4_bin DEFAULT NULL,\n  `idcard` bigint(20) NOT NULL,\n  PRIMARY KEY (`id`),\n  UNIQUE KEY `idcard` (`idcard`) \n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u63d2\u5165\u7684\u6d4b\u8bd5\u6570\u636e\uff0c\u8fd8\u662f\u548c\u4e0a\u7bc7\u6587\u7ae0\u4e2d\u7684\u4e00\u6837\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>insert into `xttblog` values(1,\u2019\u4e1a\u4f59\u8349\u2019,100),(5,'xttblog\u2019,200),\n(8,\u2019xttblog\u2019,300),(10,\u2019\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\u2019,400);<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u73b0\u5728\u6211\u4eec\u6765\u770b\u7b2c\u4e00\u79cd\u60c5\u51b5\uff0c\u7b49\u503c\u67e5\u8be2\uff0c\u6216\u8005\u8bf4\u662f\u7cbe\u786e\u67e5\u8be2\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ \u5728idcard=100\u7684\u552f\u4e00\u7d22\u5f15\u4e0a\u52a0X\u9501\n\/\/ \u5e76\u5728id=1\u7684\u805a\u7c07\u7d22\u5f15\u4e0a\u52a0X\u9501\nupdate `xttblog` set name='\u6781\u5ba2\u65f6\u95f4\u8fd4\u73b024' where idcard=100;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0a\u9762\u7684\u8fd9\u6761 SQL\uff0c\u4e0d\u7ba1\u662f\u5728 RR \u8fd8\u662f RC \u9694\u79bb\u7ea7\u522b\u4e0b\uff0c\u90fd\u4f1a\u5728\u552f\u4e00\u7d22\u5f15\u548c\u805a\u7c07\u7d22\u5f15\u4e0a\u52a0 X \u9501\uff08\u6392\u5b83\u9501\uff09\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u518d\u6765\u770b\u7b2c\u4e8c\u79cd\u60c5\u51b5\uff0c\u5982\u679c\u662f\u8303\u56f4\u67e5\u8be2\uff0c\u5728 RC \u9694\u79bb\u7ea7\u522b\u4e0b\uff0c\u4f1a\u5728\u6240\u6709\u547d\u4e2d\u7684\u552f\u4e00\u7d22\u5f15\u548c\u805a\u7c07\u7d22\u5f15\u4e0a\u52a0 record lock\uff08\u884c\u9501\uff09\u3002\u56e0\u4e3a RC \u7ea7\u522b\u4e0b\u6ca1\u6709 Gap Lock\uff0c\u6240\u4ee5\uff0c\u7406\u6240\u5f53\u7136\u7684 next-key locks \u4e5f\u5c31\u6ca1\u6709\u4e86\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4f46\u662f RR \u9694\u79bb\u7ea7\u522b\u5374\u4e0d\u4e00\u6837\u3002RR \u9694\u79bb\u7ea7\u522b\u4e0b\uff0c\u4f1a\u5728\u6240\u6709\u547d\u4e2d\u7684\u884c\u7684\u552f\u4e00\u7d22\u5f15\u4e0a\u52a0 next-key locks\u3002\u6700\u540e\u547d\u4e2d\u7684\u7d22\u5f15\u7684\u540e\u4e00\u6761\u8bb0\u5f55\uff0c\u4e5f\u4f1a\u88ab\u52a0\u4e0a next-key lock\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ \u5728idcard=100\u548cidcard=200\u7684\u552f\u4e00\u7d22\u5f15\u4e0a\u52a0X\u9501\n\/\/ \u5e76\u5728id=1\u548cid=5\u7684\u805a\u7c07\u7d22\u5f15\u4e0a\u52a0X\u9501\n\/\/ \u5e76\u5728\u552f\u4e00\u7d22\u5f15\u7684\u95f4\u9699(-\u221e,100)(100,200)\u52a0gap lock\nupdate `xttblog` set name=\u2018\u5fae\u4fe1\u53f7\uff1axttblog' where idcard&lt;150;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u4e3b\u952e\u7d22\u5f15\u4e4b\u95f4\u5e76\u6ca1\u6709\u6dfb\u52a0 Gap Lock\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6700\u540e\uff0c\u6211\u4eec\u518d\u6765\u770b\u770b\u67e5\u8be2\u7ed3\u679c\u4e3a\u7a7a\u7684\u60c5\u51b5\u3002\u540c\u6837\u7684\u5728 RC \u9694\u79bb\u7ea7\u522b\u4e0b\uff0c\u4ec0\u4e48\u4e5f\u4e0d\u4f1a\u9501\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4f46\u662f\u5728 RR \u9694\u79bb\u7ea7\u522b\u4e0b\uff0c\u539f\u672c\u52a0\u5728\u4e3b\u952e\u7d22\u5f15\u4e0a\u7684 Gap Lock\uff0c\u73b0\u5728\u88ab\u6dfb\u52a0\u5230\u552f\u4e00\u7d22\u5f15\u4e0a\u4e86\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ \u5728\u552f\u4e00\u7d22\u5f15\u7684\u95f4\u9699(100,200)\u52a0gap lock\nupdate `xttblog` set name=\u2018\u5fae\u4fe1\u53f7\uff1axttblog' where idcard=150;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u4ee5\u4e0a\u5c31\u662f\uff0c\u552f\u4e00\u7d22\u5f15\u5728 RR \u548c RC \u9694\u79bb\u7ea7\u522b\u4e0b\u7684\u52a0\u9501\u60c5\u51b5\u603b\u7ed3\u3002\u5982\u679c\u4f60\u6709\u4ec0\u4e48\u7591\u95ee\uff0c\u53ef\u4ee5\u52a0\u6211\u5fae\u4fe1\u53f7\uff1axttblog\u3002\u4e00\u8d77\u7cbe\u8fdb\uff01<\/p>\n<!-- <audio autoplay=\"autoplay\" height=\"100\" width=\"100\" hidden=\"true\"><source src=\"https:\/\/c.coka.la\/orAvPR.mp3\" type=\"audio\/mp3\"\/><\/audio><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/ws3.sinaimg.cn\/large\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/> --><p><!-- <img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/xmt1139057136\/xttblog\/master\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/>--><img decoding=\"async\" src=\"https:\/\/saas.51autoparts.cn\/api\/admin\/sys-file\/oss\/file?fileName=84db51f8561e448f9a4fda2eff0811f9.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/><\/p><p>\u6700\u540e\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u4e2a\u4eba\u5fae\u4fe1\u516c\u4f17\u53f7\uff1a\u4e1a\u4f59\u8349\uff08yyucao\uff09\uff01<b>\u53ef\u52a0\u4f5c\u8005\u5fae\u4fe1\u53f7\uff1a<font color=\"red\">xttblog2<\/font>\u3002\u5907\u6ce8\uff1a\u201c1\u201d\uff0c\u6dfb\u52a0\u535a\u4e3b\u5fae\u4fe1\u62c9\u4f60\u8fdb\u5fae\u4fe1\u7fa4\u3002\u5907\u6ce8\u9519\u8bef\u4e0d\u4f1a\u540c\u610f\u597d\u53cb\u7533\u8bf7\u3002<\/b>\u518d\u6b21\u611f\u8c22\u60a8\u7684\u5173\u6ce8\uff01\u540e\u7eed\u6709\u7cbe\u5f69\u5185\u5bb9\u4f1a\u7b2c\u4e00\u65f6\u95f4\u53d1\u7ed9\u60a8\uff01\u539f\u521b\u6587\u7ae0\u6295\u7a3f\u8bf7\u53d1\u9001\u81f3532009913@qq.com\u90ae\u7bb1\u3002\u5546\u52a1\u5408\u4f5c\u4e5f\u53ef\u6dfb\u52a0\u4f5c\u8005\u5fae\u4fe1\u8fdb\u884c\u8054\u7cfb\uff01<\/p><p>\u672c\u6587\u539f\u6587\u51fa\u5904\uff1a<a href=\"https:\/\/www.xttblog.com\">\u4e1a\u4f59\u8349<\/a>\uff1a &raquo; <a href=\"https:\/\/www.xttblog.com\/?p=4339\">MySQL \u552f\u4e00\u7d22\u5f15\u5728 RR \u548c RC \u9694\u79bb\u7ea7\u522b\u4e0b\u7684\u52a0\u9501\u60c5\u51b5\u603b\u7ed3<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>\u4e0a\u4e00\u8bb2\uff0c\u6211\u7ed9\u5927\u5bb6\u89e3\u91ca\u4e86\uff0c\u4e3b\u952e\u7d22\u5f15 RR \u548c RC \u9694\u79bb\u7ea7\u522b\u4e0b\uff0c\u7cbe\u786e\u67e5\u8be2\uff08\u7b49\u503c\u67e5\u8be2\uff09\u3001\u8303\u56f4\u67e5\u8be2\u3001\u7a7a\u503c\u67e5\u8be2\u7684\u52a0\u9501\u60c5 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[83,580,155,156,1452],"class_list":["post-4339","post","type-post","status-publish","format-standard","hentry","category-sql","tag-mysql","tag-mysql----dba","tag-sql","tag-156","tag-1452"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/4339","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4339"}],"version-history":[{"count":1,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/4339\/revisions"}],"predecessor-version":[{"id":4340,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/4339\/revisions\/4340"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4339"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4339"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4339"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}