{"id":10012,"date":"2022-07-12T08:41:04","date_gmt":"2022-07-12T00:41:04","guid":{"rendered":"https:\/\/www.gbase8.cn\/?p=10012"},"modified":"2022-07-12T14:33:02","modified_gmt":"2022-07-12T06:33:02","slug":"gbase-8a%e8%87%aa%e5%a2%9e%e5%88%97%e4%b8%8d%e5%85%81%e8%ae%b8insert%e6%8a%a5%e9%94%99auto-increment-column-should-not-be-specified-in-insert","status":"publish","type":"post","link":"https:\/\/www.gbase8.cn\/en\/10012","title":{"rendered":"\u5357\u5927\u901a\u7528GBase 8a\u81ea\u589e\u5217\u4e0d\u5141\u8bb8insert\u62a5\u9519auto_increment column should not be specified in insert"},"content":{"rendered":"<p>GBase 8a\u4eceV95\u7248\u672c\u5f00\u59cb\u652f\u6301\u81ea\u589e\u5217\uff0c\u540c\u65f6\u4e5f\u9650\u5236\u8be5\u5217\u88ab\u624b\u5de5insert,update\u7b49\u64cd\u4f5c\uff0c\u5426\u5219\u4f1a\u62a5\u9519 auto-increment column should not be specified in insert\u3002\u867d\u7136\u6709\u53c2\u6570\u4e34\u65f6\u653e\u5f00\u8fd9\u4e2a\u9650\u5236\uff0c\u4f46\u8fd8\u662f\u4e0d\u5efa\u8bae\u4f5c\u4e3a\u5e38\u89c4\u64cd\u4f5c\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-6a2aaa5e7d9b0\" 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-6a2aaa5e7d9b0\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.gbase8.cn\/en\/10012\/#%E5%8F%82%E8%80%83\" >\u53c2\u8003<\/a><\/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\/10012\/#%E6%8A%A5%E9%94%99%E6%A0%B7%E4%BE%8B\" >\u62a5\u9519\u6837\u4f8b<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.gbase8.cn\/en\/10012\/#insert_values%E6%8A%A5%E9%94%99\" >insert values\u62a5\u9519<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.gbase8.cn\/en\/10012\/#update%E6%8A%A5%E9%94%99\" >update\u62a5\u9519<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.gbase8.cn\/en\/10012\/#%E5%8E%9F%E5%9B%A0\" >\u539f\u56e0<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.gbase8.cn\/en\/10012\/#%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88\" >Solution<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.gbase8.cn\/en\/10012\/#%E9%81%BF%E5%85%8D%E6%9B%B4%E6%96%B0%E8%87%AA%E5%A2%9E%E5%88%97\" >\u907f\u514d\u66f4\u65b0\u81ea\u589e\u5217<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.gbase8.cn\/en\/10012\/#%E4%B8%B4%E6%97%B6%E5%85%81%E8%AE%B8%E5%8F%82%E6%95%B0\" >\u4e34\u65f6\u5141\u8bb8\u53c2\u6570<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%8F%82%E8%80%83\"><\/span>\u53c2\u8003<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p><a href=\"https:\/\/www.gbase8.cn\/en\/1073\/?hilite=%E8%87%AA%E5%A2%9E%E5%88%97\">GBase 8a \u5728V95\u7248\u672c\u5bf9\u8868<mark>\u81ea\u589e\u5217<\/mark>auto_increment\u7684\u652f\u6301\u6837\u4f8b<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E6%8A%A5%E9%94%99%E6%A0%B7%E4%BE%8B\"><\/span>\u62a5\u9519\u6837\u4f8b<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"insert_values%E6%8A%A5%E9%94%99\"><\/span>insert values\u62a5\u9519<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>gbase&gt; insert into t_inc values(1,'First');\nERROR 1733 (HY000): (GBA-01EX-700) Gbase general error: auto-increment column should not be specified in insert(...)<\/code><\/pre>\n\n\n\n<p>insert select\u62a5\u9519<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>gbase&gt; insert into t_inc select * from t_inc;\nERROR 1733 (HY000): (GBA-01EX-700) Gbase general error: auto-increment column should not be specified in insert select<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"update%E6%8A%A5%E9%94%99\"><\/span>update\u62a5\u9519<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>gbase&gt; update t_inc set id=1 where id=1;\nERROR 1235 (42000): This version of GBase doesn't yet support 'update\/merge on auto_increment column'<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%8E%9F%E5%9B%A0\"><\/span>\u539f\u56e0<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>GBase 8a\u7684\u81ea\u589e\u5217\uff0c\u4e0d\u652f\u6301insert,update\u7b49\u64cd\u4f5c\uff0c<span class=\"has-inline-color has-luminous-vivid-orange-color\">\u9664\u4e86\u8bbe\u7f6e\u4e3adefault,0,null\u5916<\/span>\u3002 <\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>gbase> show create table t3_inc;\r\n| Table  | Create Table                                                                                                                                                                                  |\r\n| t3_inc | CREATE TABLE \"t3_inc\" (\r\n  \"id\" bigint(20) NOT NULL AUTO_INCREMENT,\r\n  \"name\" varchar(100) DEFAULT NULL,\r\n  PRIMARY KEY (\"id\")\r\n) ENGINE=EXPRESS DEFAULT CHARSET=utf8 TABLESPACE='sys_tablespace' |\r\n1 row in set (Elapsed: 00:00:00.00)\n\ngbase> insert into t3_inc  values(0,'9999');\r\nQuery OK, 1 row affected (Elapsed: 00:00:00.10)\r\n\r\ngbase> select * from t3_inc;\r\n+----+----------+\r\n| id | name     |\r\n+----+----------+\r\n|  1 | t3_first |\r\n|  2 | t3_first |\r\n|  3 | t3_first |\r\n|  6 | 333      |\r\n|  9 | 444      |\r\n| 10 | t3_first |\r\n| 11 | 9999     |\r\n+----+----------+\r\n7 rows in set (Elapsed: 00:00:00.01)\n\r\n\r\ngbase> insert into t3_inc  values(null,'9999');\r\nQuery OK, 1 row affected (Elapsed: 00:00:00.10)\r\n\r\ngbase> select * from t3_inc;\r\n+----+----------+\r\n| id | name     |\r\n+----+----------+\r\n|  1 | t3_first |\r\n|  2 | t3_first |\r\n|  3 | t3_first |\r\n|  6 | 333      |\r\n|  9 | 444      |\r\n| 10 | t3_first |\r\n| 11 | 9999     |\r\n| 12 | 9999     |\r\n+----+----------+\r\n8 rows in set (Elapsed: 00:00:00.01)\r\n\r\ngbase> insert into t3_inc  values(default,'9999');\r\nQuery OK, 1 row affected (Elapsed: 00:00:00.10)\r\n\r\ngbase> select * from t3_inc;\r\n+----+----------+\r\n| id | name     |\r\n+----+----------+\r\n|  1 | t3_first |\r\n|  2 | t3_first |\r\n|  3 | t3_first |\r\n|  6 | 333      |\r\n|  9 | 444      |\r\n| 10 | t3_first |\r\n| 11 | 9999     |\r\n| 12 | 9999     |\r\n| 13 | 9999     |\r\n+----+----------+\r\n9 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=\"%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88\"><\/span>Solution<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E9%81%BF%E5%85%8D%E6%9B%B4%E6%96%B0%E8%87%AA%E5%A2%9E%E5%88%97\"><\/span>\u907f\u514d\u66f4\u65b0\u81ea\u589e\u5217<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>\u65e2\u7136\u9009\u62e9\u4e86\u81ea\u589e\u5217\uff0c\u90a3\u4e48\u5c31\u4e0d\u8981\u6307\u5b9a\u8be5\u5217\u7684\u503c\uff0c\u4e5f\u5c31\u81ea\u52a8\u907f\u514d\u4e86\u3010\u91cd\u590d\u3011\u3002\u5728insert update\u64cd\u4f5c\u65f6\u4e0d\u8981\u5bf9\u81ea\u589e\u5217\u505a\u4e3b\u52a8\u4fee\u6539\u5373\u53ef\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>gbase&gt; select * from t_inc;\n+----+-------+\n| id | name  |\n+----+-------+\n|  1 | First |\n+----+-------+\n1 row in set (Elapsed: 00:00:00.01)\n\n\ngbase&gt; insert into t_inc (name) values ('Second');\nQuery OK, 1 row affected (Elapsed: 00:00:00.11)\n\ngbase&gt; select * from t_inc;\n+----+--------+\n| id | name   |\n+----+--------+\n|  1 | First  |\n|  2 | Second |\n+----+--------+\n2 rows in set (Elapsed: 00:00:00.01)\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E4%B8%B4%E6%97%B6%E5%85%81%E8%AE%B8%E5%8F%82%E6%95%B0\"><\/span>\u4e34\u65f6\u5141\u8bb8\u53c2\u6570<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>\u5f53\u8868\u521d\u59cb\u5316\u65f6\uff0c\u4e5f\u662f\u6709\u53ef\u80fd\u8981\u6309\u7167\u9884\u8bbe\u7684\u503c\u63d2\u5165\u6570\u636e\u7684\uff0c\u6b64\u65f6\u53ef\u4ee5\u901a\u8fc7\u4e00\u4e2a\u53c2\u6570\u4e34\u65f6\u6253\u5f00\u8fd9\u4e2a\u9650\u5236\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>_gbase_auto_increment_allow_insert<\/code><\/pre>\n\n\n\n<p>\u8be5\u53c2\u6570\u9ed8\u8ba4\u4e3a0\uff0c\u4e0d\u5141\u8bb8insert<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>gbase&gt; show variables like '%increment%';\n+------------------------------------+-------+\n| Variable_name                      | Value |\n+------------------------------------+-------+\n| _gbase_auto_increment_allow_insert | OFF   |\n| _gbase_auto_increment_base         | 0     |\n| auto_increment_increment           | 1     |\n| auto_increment_offset              | 1     |\n| div_precision_increment            | 4     |\n+------------------------------------+-------+\n5 rows in set (Elapsed: 00:00:00.00)\n<\/code><\/pre>\n\n\n\n<p>\u901a\u8fc7set \u8bed\u53e5\u8bbe\u7f6e\u8be5\u53c2\u6570\uff0c\u652f\u6301session\u7ea7\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>gbase&gt; set _gbase_auto_increment_allow_insert=1;\nQuery OK, 0 rows affected (Elapsed: 00:00:00.00)\n\ngbase&gt; show variables like '%increment%';\n+------------------------------------+-------+\n| Variable_name                      | Value |\n+------------------------------------+-------+\n| _gbase_auto_increment_allow_insert | ON    |\n| _gbase_auto_increment_base         | 0     |\n| auto_increment_increment           | 1     |\n| auto_increment_offset              | 1     |\n| div_precision_increment            | 4     |\n+------------------------------------+-------+\n5 rows in set (Elapsed: 00:00:00.00)\n<\/code><\/pre>\n\n\n\n<p>\u4e4b\u540e\u5c31\u53ef\u4ee5\u5bf9\u8be5\u8868\u505ainsert\u4e86\uff0c<span class=\"has-inline-color has-luminous-vivid-orange-color\">\u4f46\u6ce8\u610f\uff0c\u4e0d\u518d\u4fdd\u8bc1\u81ea\u589e\u5217\u6570\u636e\u7684\u552f\u4e00\u6027\u3002\u8bf7\u7528\u6237\u81ea\u884c\u907f\u514d\u81ea\u589e\u5217\u7684\u6570\u503c\u91cd\u590d\u3002<\/span><\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>gbase&gt; select * from t_inc;\n+----+--------+\n| id | name   |\n+----+--------+\n|  1 | First  |\n|  2 | Second |\n|  3 | Second |\n+----+--------+\n3 rows in set (Elapsed: 00:00:00.02)\n\ngbase&gt; set _gbase_auto_increment_allow_insert=1;\nQuery OK, 0 rows affected (Elapsed: 00:00:00.01)\n\ngbase&gt; insert into t_inc values (1,'First2');\nQuery OK, 1 row affected (Elapsed: 00:00:00.10)\n\ngbase&gt; select * from t_inc;\n+----+--------+\n| id | name   |\n+----+--------+\n|  1 | First  |\n|  2 | Second |\n|  3 | Second |\n|  1 | First2 |\n+----+--------+\n4 rows in set (Elapsed: 00:00:00.01)\n\n<\/code><\/pre>\n\n\n\n<p>\u5982\u679c\u6062\u590d\u53c2\u6570\uff0c\u5219\u4e0b\u4e00\u4e2a\u81ea\u589e\u5217\u7684\u503c\uff0c\u4f1a\u81ea\u52a8\u8ba1\u7b97\u3002\u5982\u4e0b\u624b\u5de5insert\u5230\u4e86id=100\uff0c\u5173\u95ed\u53c2\u6570\u540e\uff0c\u81ea\u589e\u7684\u5217\u4f1a\u4fdd\u8bc1\u4e0b\u4e00\u4e2a\u6570\u503c\u6bd4\u5f53\u524d\u6700\u5927\u7684\u66f4\u5927\uff0c\u786e\u4fdd\u81ea\u589e\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>gbase&gt; insert into t_inc values (100,'First100');\nQuery OK, 1 row affected (Elapsed: 00:00:00.10)\n\ngbase&gt; select * from t_inc;\n+-----+----------+\n| id  | name     |\n+-----+----------+\n|   1 | First    |\n|   2 | Second   |\n|   3 | Second   |\n|   1 | First2   |\n| 100 | First100 |\n+-----+----------+\n5 rows in set (Elapsed: 00:00:00.01)\n\ngbase&gt; set _gbase_auto_increment_allow_insert=0;\nQuery OK, 0 rows affected (Elapsed: 00:00:00.01)\n\ngbase&gt; insert into t_inc (name) values ('101test');\nQuery OK, 1 row affected (Elapsed: 00:00:00.10)\n\ngbase&gt; select * from t_inc;\n+-----+----------+\n| id  | name     |\n+-----+----------+\n|   1 | First    |\n|   2 | Second   |\n|   3 | Second   |\n|   1 | First2   |\n| 100 | First100 |\n| 101 | 101test  |\n+-----+----------+\n6 rows in set (Elapsed: 00:00:00.00)\n\n<\/code><\/pre>","protected":false},"excerpt":{"rendered":"<p>\u5357\u5927\u901a\u7528GBase 8a\u4eceV95\u7248\u672c\u5f00\u59cb\u652f\u6301\u81ea\u589e\u5217\uff0c\u540c\u65f6\u4e5f\u9650\u5236\u8be5\u5217\u88ab\u624b\u5de5insert,update\u7b49\u64cd\u4f5c\uff0c\u5426\u5219\u4f1a\u62a5\u9519 auto-increment column should not be specified in insert\u3002\u867d\u7136\u6709\u53c2\u6570\u4e34\u65f6\u653e\u5f00\u8fd9\u4e2a\u9650\u5236\uff0c\u4f46\u8fd8\u662f\u4e0d\u5efa\u8bae\u4f5c\u4e3a\u5e38\u89c4\u64cd\u4f5c\u3002<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,54],"tags":[60],"class_list":{"0":"post-10012","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-gbase8a","8":"tag-v95"},"_links":{"self":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts\/10012","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=10012"}],"version-history":[{"count":10,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts\/10012\/revisions"}],"predecessor-version":[{"id":10065,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts\/10012\/revisions\/10065"}],"wp:attachment":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/media?parent=10012"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/categories?post=10012"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/tags?post=10012"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}