{"id":990,"date":"2020-09-06T19:27:19","date_gmt":"2020-09-06T11:27:19","guid":{"rendered":"http:\/\/www.gbase8.cn\/?p=990"},"modified":"2020-09-08T07:09:55","modified_gmt":"2020-09-07T23:09:55","slug":"gbase-8a-boolean%e7%b1%bb%e5%9e%8b%e7%9a%84insert-update%e6%93%8d%e4%bd%9c","status":"publish","type":"post","link":"https:\/\/www.gbase8.cn\/en\/990","title":{"rendered":"\u5357\u5927\u901a\u7528GBase 8a boolean\u7c7b\u578b\u7684insert update\u64cd\u4f5c"},"content":{"rendered":"<p>GBase 8a \u6570\u636e\u5e93\u652f\u6301boolean\u7c7b\u578b\uff0c\u4f46\u5b9e\u8d28\u5185\u90e8\u662f\u7528tinyint \u76840\u548c1\u5b9e\u73b0\u7684\u30020\u8868\u793afalse, 1\u8868\u793atrue\u3002\u5bf9boolean\u7c7b\u578b\u7684\u64cd\u4f5c\uff0c\u65e2\u53ef\u4ee5\u7528true,false\uff0c\u4e5f\u53ef\u4ee5\u76f4\u63a5\u75280\u548c1\u3002<\/p>\n\n\n\n<p>\u5982\u4e0b\u662f\u4ee3\u7801\u6f14\u793a\u3002<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_84 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Directory Navigation<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a2b3cf09164b\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewbox=\"0 0 24 24\" version=\"1.2\" baseprofile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a2b3cf09164b\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1' ><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.gbase8.cn\/en\/990\/#%E5%BB%BA%E8%A1%A8\" >\u5efa\u8868<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.gbase8.cn\/en\/990\/#%E6%8F%92%E5%85%A5Insert\" >\u63d2\u5165Insert<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.gbase8.cn\/en\/990\/#%E6%9D%A1%E4%BB%B6%E6%9F%A5%E8%AF%A2Select\" >\u6761\u4ef6\u67e5\u8be2Select<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.gbase8.cn\/en\/990\/#%E6%9B%B4%E6%96%B0update\" >\u66f4\u65b0update<\/a><\/li><\/ul><\/nav><\/div>\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%BB%BA%E8%A1%A8\"><\/span>\u5efa\u8868<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>\u53ef\u4ee5\u770b\u5230\u5185\u90e8\u5c31\u662f\u7528tinyint(1)\u4ee3\u66ff\u7684\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gbase> create table testboolean(id int, bool boolean);\nQuery OK, 0 rows affected (Elapsed: 00:00:00.16)\n\ngbase> desc testboolean;\n+-------+------------+------+-----+---------+-------+\n| Field | Type       | Null | Key | Default | Extra |\n+-------+------------+------+-----+---------+-------+\n| id    | int(11)    | YES  |     | NULL    |       |\n| bool  | tinyint(1) | YES  |     | NULL    |       |\n+-------+------------+------+-----+---------+-------+\n2 rows in set (Elapsed: 00:00:00.00)\n\ngbase> show create table testboolean;\n+-------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table       | Create Table                                                                                                                                                 |\n+-------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| testboolean | CREATE TABLE \"testboolean\" (\n  \"id\" int(11) DEFAULT NULL,\n  \"bool\" tinyint(1) DEFAULT NULL\n) ENGINE=EXPRESS DEFAULT CHARSET=utf8 TABLESPACE='sys_tablespace' |\n+-------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (Elapsed: 00:00:00.00)\n\ngbase>\n\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E6%8F%92%E5%85%A5Insert\"><\/span>\u63d2\u5165Insert<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>insert\u662f\u65e2\u53ef\u4ee5\u7528true,\u4e5f\u53ef\u4ee5\u75281\uff0c\u7ed3\u679c\u90fd\u662f\u4e00\u6837\u7684\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gbase> insert into testboolean values(1,true);\nQuery OK, 1 row affected (Elapsed: 00:00:00.08)\n\ngbase> insert into testboolean values(2,false);\nQuery OK, 1 row affected (Elapsed: 00:00:00.08)\n\ngbase> insert into testboolean values(3,1);\n\\Query OK, 1 row affected (Elapsed: 00:00:00.07)\n\ngbase> insert into testboolean values(4,0);\nQuery OK, 1 row affected (Elapsed: 00:00:00.08)\n\ngbase> select * from testboolean;\n+------+------+\n| id   | bool |\n+------+------+\n|    1 |    1 |\n|    2 |    0 |\n|    3 |    1 |\n|    4 |    0 |\n+------+------+\n4 rows in set (Elapsed: 00:00:00.01)\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E6%9D%A1%E4%BB%B6%E6%9F%A5%E8%AF%A2Select\"><\/span>\u6761\u4ef6\u67e5\u8be2Select<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u67e5\u8be2\u6761\u4ef6\u4e5f\u540c\u6837\u53ef\u4ee5\u7528true\u548c1\uff0c false\u548c0.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gbase> select * from testboolean where bool=true;\n+------+------+\n| id   | bool |\n+------+------+\n|    1 |    1 |\n|    3 |    1 |\n+------+------+\n2 rows in set (Elapsed: 00:00:00.01)\n\ngbase> select * from testboolean where bool=1;\n+------+------+\n| id   | bool |\n+------+------+\n|    1 |    1 |\n|    3 |    1 |\n+------+------+\n2 rows in set (Elapsed: 00:00:00.00)\n\ngbase> select * from testboolean where bool=false;\n+------+------+\n| id   | bool |\n+------+------+\n|    2 |    0 |\n|    4 |    0 |\n+------+------+\n2 rows in set (Elapsed: 00:00:00.00)\n\ngbase> select * from testboolean where bool=0;\n+------+------+\n| id   | bool |\n+------+------+\n|    2 |    0 |\n|    4 |    0 |\n+------+------+\n2 rows in set (Elapsed: 00:00:00.00)\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E6%9B%B4%E6%96%B0update\"><\/span>\u66f4\u65b0update<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u4e00\u6837\u7684\u53ef\u4ee5\u4f7f\u75280\u548c1\u4ee3\u66fffalse,true\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gbase> update testboolean set bool=true where bool=false and id=2;\nQuery OK, 1 row affected (Elapsed: 00:00:00.07)\nRows matched: 1  Changed: 1  Warnings: 0\n\ngbase> select * from testboolean;\n+------+------+\n| id   | bool |\n+------+------+\n|    1 |    1 |\n|    2 |    1 |\n|    3 |    1 |\n|    4 |    0 |\n+------+------+\n4 rows in set (Elapsed: 00:00:00.00)\n\ngbase> update testboolean set bool=0 where bool=1 and id=2;\nQuery OK, 1 row affected (Elapsed: 00:00:00.10)\nRows matched: 1  Changed: 1  Warnings: 0\n\ngbase> select * from testboolean;\n+------+------+\n| id   | bool |\n+------+------+\n|    1 |    1 |\n|    2 |    0 |\n|    3 |    1 |\n|    4 |    0 |\n+------+------+\n4 rows in set (Elapsed: 00:00:00.01)\n<\/code><\/pre>\n\n\n\n<p><\/p>","protected":false},"excerpt":{"rendered":"<p>\u5357\u5927\u901a\u7528GBase 8a \u6570\u636e\u5e93\u652f\u6301boolean\u7c7b\u578b\uff0c\u4f46\u5b9e\u8d28\u5185\u90e8\u662f\u7528tinyint \u76840\u548c1\u5b9e\u73b0\u7684\u30020\u8868\u793afalse, 1\u8868\u793atrue\u3002\u5bf9boolean\u7c7b\u578b\u7684\u64cd\u4f5c\uff0c\u65e2\u53ef\u4ee5\u7528true,false\uff0c\u4e5f\u53ef\u4ee5\u76f4\u63a5\u75280\u548c1\u3002<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-990","post","type-post","status-publish","format-standard","hentry","category-gbase8a"],"_links":{"self":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts\/990","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/comments?post=990"}],"version-history":[{"count":1,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts\/990\/revisions"}],"predecessor-version":[{"id":991,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts\/990\/revisions\/991"}],"wp:attachment":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/media?parent=990"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/categories?post=990"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/tags?post=990"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}