{"id":1902,"date":"2019-04-23T14:53:34","date_gmt":"2019-04-23T06:53:34","guid":{"rendered":"https:\/\/www.yusian.com\/blog\/?p=1902"},"modified":"2020-12-02T14:55:55","modified_gmt":"2020-12-02T06:55:55","slug":"dtl-%e4%ba%8b%e5%8a%a1%e6%8e%a7%e5%88%b6%e8%af%ad%e8%a8%80","status":"publish","type":"post","link":"https:\/\/www.yusian.com\/blog\/database\/2019\/04\/23\/1453341902.html","title":{"rendered":"DTL \u4e8b\u52a1\u63a7\u5236\u8bed\u8a00"},"content":{"rendered":"<h3>1\u3001\u4e00\u4e2a\u7b80\u5355\u7684\u4e8b\u52a1<\/h3>\n<ul>\n<li>\u5f00\u542f\u4e8b\u52a1\uff1astart transaction<\/li>\n<li>\u56de\u6eda\u4e8b\u52a1\uff1arollback<\/li>\n<li>\u63d0\u4ea4\u4e8b\u52a1\uff1acommit<\/li>\n<\/ul>\n<pre><code class=\"language-sql line-numbers\">mysql&gt; start transaction;\nQuery OK, 0 rows affected (0.00 sec)\n\n\nmysql&gt; update user set fee = 1200 where id = 1;\nQuery OK, 1 row affected (0.00 sec)\nRows matched: 1  Changed: 1  Warnings: 0\n\n\nmysql&gt; select * from user;\n+----+-----------+-----+----------------------------------+-----------------+---------+---------+-----+---------------------+\n| id | user_name | sex | password                         | email           | address | fee     | age | create_at           |\n+----+-----------+-----+----------------------------------+-----------------+---------+---------+-----+---------------------+\n|  1 | sian      | \u7537  | e10adc3949ba59abbe56e057f20f883e | yusian@163.com  | NULL    | 1200.00 |  32 | 2019-04-23 14:45:36 |\n|  2 | \u4f59\u897f\u5b89    | \u7537  | c4ca4238a0b923820dcc509a6f75849b | yusian@163.com  | NULL    |    1.00 |  33 | 2019-04-21 17:12:55 |\n|  3 | Jack      | \u7537  | c81e728d9d4c2f636f067f89cc14862c | jack@yusian.com | NULL    |    0.00 |  22 | 2019-04-21 20:11:59 |\n|  4 | Rose      | \u5973  | eccbc87e4b5ce2fe28308fd9f2a7baf3 | rose@yusian.com | NULL    |    0.00 |  18 | 2019-04-22 10:46:41 |\n|  5 | Sim       | \u5973  | a87ff679a2f3e71d9181a67b7542122c | sim@yusian.com  | NULL    |    0.00 |  28 | 2019-04-22 10:46:41 |\n|  6 | Tony      | \u7537  | c4ca4238a0b923820dcc509a6f75849b | tony@yusian.com | NULL    |    0.00 |  22 | 2019-04-21 20:41:26 |\n+----+-----------+-----+----------------------------------+-----------------+---------+---------+-----+---------------------+\n6 rows in set (0.00 sec)\n\n\nmysql&gt; rollback;\nQuery OK, 0 rows affected (0.00 sec)\n\n\nmysql&gt; select * from user;\n+----+-----------+-----+----------------------------------+-----------------+---------+---------+-----+---------------------+\n| id | user_name | sex | password                         | email           | address | fee     | age | create_at           |\n+----+-----------+-----+----------------------------------+-----------------+---------+---------+-----+---------------------+\n|  1 | sian      | \u7537  | e10adc3949ba59abbe56e057f20f883e | yusian@163.com  | NULL    | 1100.00 |  32 | 2019-04-23 14:38:53 |\n|  2 | \u4f59\u897f\u5b89    | \u7537  | c4ca4238a0b923820dcc509a6f75849b | yusian@163.com  | NULL    |    1.00 |  33 | 2019-04-21 17:12:55 |\n|  3 | Jack      | \u7537  | c81e728d9d4c2f636f067f89cc14862c | jack@yusian.com | NULL    |    0.00 |  22 | 2019-04-21 20:11:59 |\n|  4 | Rose      | \u5973  | eccbc87e4b5ce2fe28308fd9f2a7baf3 | rose@yusian.com | NULL    |    0.00 |  18 | 2019-04-22 10:46:41 |\n|  5 | Sim       | \u5973  | a87ff679a2f3e71d9181a67b7542122c | sim@yusian.com  | NULL    |    0.00 |  28 | 2019-04-22 10:46:41 |\n|  6 | Tony      | \u7537  | c4ca4238a0b923820dcc509a6f75849b | tony@yusian.com | NULL    |    0.00 |  22 | 2019-04-21 20:41:26 |\n+----+-----------+-----+----------------------------------+-----------------+---------+---------+-----+---------------------+\n6 rows in set (0.00 sec)\n<\/code><\/pre>\n<p><!--more--><\/p>\n<h3>2\u3001\u81ea\u52a8\u63d0\u4ea4\u8bbe\u7f6e<\/h3>\n<ul>\n<li>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u6bcf\u6b21\u6267\u884csql\u8bed\u53e5\u90fd\u4f1a\u81ea\u52a8\u63d0\u4ea4(commit)\uff1b<\/li>\n<li>\u67e5\u770b\u5f53\u524d\u81ea\u52a8\u63d0\u4ea4\u72b6\u6001\uff1ashow variables like \u2018%autocommit%\u2019\u6216select @@global.autocommit<\/li>\n<\/ul>\n<pre><code class=\"language-sql line-numbers\">mysql&gt; show variables like '%autocommit%';\n+---------------+-------+\n| Variable_name | Value |\n+---------------+-------+\n| autocommit    | ON    |\n+---------------+-------+\n1 row in set (0.00 sec)\n\n\nmysql&gt; set autocommit = off;\nQuery OK, 0 rows affected (0.00 sec)\n\n\nmysql&gt; show variables like '%autocommit%';\n+---------------+-------+\n| Variable_name | Value |\n+---------------+-------+\n| autocommit    | OFF   |\n+---------------+-------+\n1 row in set (0.00 sec)\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>1\u3001\u4e00\u4e2a\u7b80\u5355\u7684\u4e8b\u52a1 \u5f00\u542f\u4e8b\u52a1\uff1astart transaction \u56de\u6eda\u4e8b\u52a1\uff1arollback \u63d0\u4ea4\u4e8b\u52a1\uff1acommit mysql&gt; start transaction; Query OK, 0 rows affected (0.00 sec) mysql&gt; update user set fee = 1200 where id = 1; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql&gt; select * from user; +&#8212;-+&#8212;&#8212;&#8212;&#8211;+&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+ | id | user_name | sex | password | [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[282],"tags":[327,329,22],"class_list":["post-1902","post","type-post","status-publish","format-standard","hentry","category-database","tag-database","tag-dtl","tag-mysql"],"_links":{"self":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/posts\/1902","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/comments?post=1902"}],"version-history":[{"count":0,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/posts\/1902\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/media?parent=1902"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/categories?post=1902"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/tags?post=1902"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}