{"id":8310,"date":"2021-11-01T15:55:38","date_gmt":"2021-11-01T07:55:38","guid":{"rendered":"https:\/\/www.gbase8.cn\/?p=8310"},"modified":"2022-01-24T16:45:02","modified_gmt":"2022-01-24T08:45:02","slug":"gbase-8a%e5%ae%89%e5%85%a8%e9%87%8d%e5%bb%ba%e8%a1%a8%e7%9a%84%e4%b8%80%e4%b8%aa%e6%96%b9%e6%a1%88","status":"publish","type":"post","link":"https:\/\/www.gbase8.cn\/en\/8310","title":{"rendered":"\u5357\u5927\u901a\u7528GBase 8a\u5b89\u5168\u91cd\u5efa\u8868\u7684\u4e00\u4e2a\u65b9\u6848"},"content":{"rendered":"<p>\u5f53\u7531\u4e8e\u67d0\u4e9b\u539f\u56e0\u9700\u8981\u91cd\u5efa\u8868\u65f6\uff0c\u9700\u8981\u9501\u5b9a\u8868\uff0c\u907f\u514d\u8be5\u8868\u5728\u91cd\u5efa\u671f\u95f4\u53c8\u88ab\u66f4\u6539\uff0c\u5bfc\u81f4\u65b0\u8868\u548c\u8001\u8868\u6570\u636e\u4e0d\u4e00\u81f4\u3002\u672c\u6587\u63d0\u4f9b\u4e00\u4e2a\u5e94\u7528\u5c42\u7684\u5b89\u5168\u91cd\u5efa\u65b9\u6848\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-6a2b0c3c5f228\" 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-6a2b0c3c5f228\"  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\/8310\/#%E8%AD%A6%E5%91%8A\" >\u8b66\u544a<\/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\/8310\/#%E6%96%B9%E6%A1%88%E5%86%85%E5%AE%B9\" >\u65b9\u6848\u5185\u5bb9<\/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\/8310\/#%E5%AE%9E%E7%8E%B0%E4%BE%8B%E5%AD%90\" >\u5b9e\u73b0\u4f8b\u5b50<\/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\/8310\/#%E6%89%A7%E8%A1%8C%E6%95%88%E6%9E%9C\" >\u6267\u884c\u6548\u679c<\/a><\/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\/8310\/#%E5%AF%B9%E5%85%B6%E5%AE%83%E4%B8%9A%E5%8A%A1%E7%9A%84%E5%BD%B1%E5%93%8D\" >\u5bf9\u5176\u5b83\u4e1a\u52a1\u7684\u5f71\u54cd<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E8%AD%A6%E5%91%8A\"><\/span>\u8b66\u544a<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u572895\u7684\u7248\u672c(\u622a\u6b622022-01-24)\uff0c\u6d4b\u8bd5\u53d1\u73b0dml\u3001ddl\u4f1a\u91ca\u653e\u6389\u9501\uff0c\u5bfc\u81f4\u540e\u9762\u65e0\u6cd5\u4e32\u884c\u6267\u884c\u3002\u5982\u6709\u65b0\u65b9\u6848\u6216\u6539\u8fdb\uff0c\u4f1a\u66f4\u65b0\u672c\u6587\u6863\u3002<\/p>\n\n\n\n<p>\u76ee\u524d\u7248\u672c\u53ea\u9488\u5bf9862\u6709\u6548\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E6%96%B9%E6%A1%88%E5%86%85%E5%AE%B9\"><\/span>\u65b9\u6848\u5185\u5bb9<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u8be5\u65b9\u6848\u901a\u8fc7\u5982\u4e0b\u51e0\u4e2a\u6b65\u9aa4\u6765\u5b9e\u73b0<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u9501\u4f4f\u8868<\/li><li>\u5efa\u4e00\u4e2a\u65b0\u8868\uff0c\u7ed3\u6784\u548c\u539f\u6709\u7684\u4e00\u6837<\/li><li>\u5c06\u6570\u636e\u4ece\u539f\u6709\u8868\u8fc1\u79fb\u5230\u65b0\u8868<\/li><li>\u5c06\u539f\u6709\u8868\u6539\u540d<\/li><li>\u5c06\u65b0\u8868\u6539\u540d\u6210\u539f\u6709\u8868<\/li><li>\u91ca\u653e\u9501<\/li><li>\u5c06\u6539\u540d\u7684\u8001\u8868\u5220\u9664\u3010\u53ef\u9009\u3011<\/li><\/ul>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%AE%9E%E7%8E%B0%E4%BE%8B%E5%AD%90\"><\/span>\u5b9e\u73b0\u4f8b\u5b50<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u5982\u4e0b\u7684\u4e00\u4e2ashell\u811a\u672c\uff0c\u4f20\u51652\u4e2a\u53c2\u6570\uff0c\u5e93\u540d\u548c\u8868\u540d\uff0c\u8fde\u63a5\u6570\u636e\u5e93\u7684\u7528\u6237\u540d\u548c\u5bc6\u7801\uff0c\u9700\u8981\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u505a\u4fee\u6539\u3002\u5176\u4e2d\u7684sign\u662f\u65b9\u4fbf\u67e5\u627e\u54ea\u4e9b\u8868\u505a\u4e86\u5904\u7406\u7684\u4e00\u4e2a\u4e34\u65f6\u8868\u540d\u6807\u5fd7\u3002<\/p>\n\n\n\n<p>\u5982\u4e0b\u4f8b\u5b50\u6ca1\u6709\u5305\u542b\u5220\u9664\u8001\u8868\u7684\u90e8\u5206\uff0c<span class=\"has-inline-color has-luminous-vivid-orange-color\">\u5efa\u8bae\u8fdb\u884c\u4eba\u5de5\u786e\u8ba4\u540e\uff0c\u518d\u5220\u9664\u8001\u8868\uff0c\u907f\u514d\u64cd\u4f5c\u5931\u8bef\u5bfc\u81f4\u6570\u636e\u4e22\u5931<\/span>\u3002<\/p>\n\n\n\n<p>\u8be5\u811a\u672c\u5f00\u59cb\u6e05\u7406\u4e86\u6b8b\u7559\u8868\uff0c\u4e3a\u4e86\u5b89\u5168\uff0c\u9ed8\u8ba4\u662f\u6ce8\u91ca\u6389\u7684\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;gbase@rh6-1 ~]$ cat gbase_rebuild_table.sh\ndbname=$1\ntablename=$2\nsign='ABCDEFG'\necho --${tablename}--\ngccli -ugbase -pXXXXX -vvv -D${dbname} &lt;&lt;EOF\n-- drop table if exists ${tablename}_${sign}_OLD;\n-- drop table if exists ${tablename}_${sign}_NEW;\nlock table  ${tablename} write;\ncreate table ${tablename}_${sign}_NEW like ${tablename};\ninsert into ${tablename}_${sign}_NEW select * from  ${tablename};\nrename table  ${tablename} to ${tablename}_${sign}_OLD;\nrename table ${tablename}_${sign}_NEW to  ${tablename};\nunlock tables;\nEOF\n&#91;gbase@rh6-1 ~]$<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E6%89%A7%E8%A1%8C%E6%95%88%E6%9E%9C\"><\/span>\u6267\u884c\u6548\u679c<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;gbase@rh6-1 ~]$ sh gbase_rebuild_table.sh testdb t2\n--t2--\n--------------\ndrop table if exists t2_ABCDEFG_OLD\n--------------\n\nQuery OK, 0 rows affected, 3 warnings (Elapsed: 00:00:00.11)\n\n--------------\ndrop table if exists t2_ABCDEFG_NEW\n--------------\n\nQuery OK, 0 rows affected, 3 warnings (Elapsed: 00:00:00.23)\n\n--------------\nlock table  t2 write\n--------------\n\nQuery OK, 0 rows affected (Elapsed: 00:00:00.00)\n\n--------------\ncreate table t2_ABCDEFG_NEW like t2\n--------------\n\nQuery OK, 0 rows affected (Elapsed: 00:00:00.39)\n\n--------------\ninsert into t2_ABCDEFG_NEW select * from  t2\n--------------\n\nQuery OK, 0 rows affected (Elapsed: 00:00:00.10)\nRecords: 0  Duplicates: 0  Warnings: 0\n\n--------------\nrename table  t2 to t2_ABCDEFG_OLD\n--------------\n\nQuery OK, 0 rows affected (Elapsed: 00:00:01.24)\n\n--------------\nrename table t2_ABCDEFG_NEW to  t2\n--------------\n\nQuery OK, 0 rows affected (Elapsed: 00:00:00.93)\n\n--------------\nunlock tables\n--------------\n\nQuery OK, 0 rows affected (Elapsed: 00:00:00.00)\n\nBye\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%AF%B9%E5%85%B6%E5%AE%83%E4%B8%9A%E5%8A%A1%E7%9A%84%E5%BD%B1%E5%93%8D\"><\/span>\u5bf9\u5176\u5b83\u4e1a\u52a1\u7684\u5f71\u54cd<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u7ecf\u6d4b\u8bd5\uff0c\u5728lock\u671f\u95f4\uff0c\u8be5\u8868\u53ef\u4ee5\u7ee7\u7eed\u67e5\u8be2\uff0c\u4f46\u6240\u6709DML,DDL\u5c06\u963b\u585e\uff0c\u76f4\u5230unlock tables. \u4e4b\u540e\u963b\u585e\u7684SQL\u5c06\u7ee7\u7eed\u8fd0\u884c\uff0c\u6216\u8005\u963b\u585e\u8d85\u65f6\u800c\u62a5\u9519\u9000\u51fa\u3002<\/p>\n\n\n\n<p>\u8fde\u63a5\u65ad\u5f00\uff0c\u9501\u4f1a\u81ea\u52a8\u91ca\u653e\u3002<\/p>\n\n\n\n<p>\u6301\u6709\u8868\u9501\u7684session\uff0c\u8be5\u8868\u88abrename, \u751a\u81f3drop,\u5e76\u4e0d\u4f1a\u5bfc\u81f4\u9501\u88ab\u91ca\u653e\u3002\u5176\u5b83session\u5982\u679c\u5bf9\u8be5\u8868\u505a\u64cd\u4f5c\uff0c\u4f9d\u7136\u4f1a\u7b49\u5f85\u8868\u9501\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gbase&gt; create table t2 like t1;\n^CQuery aborted by Ctrl+C\nERROR 1727 (HY000): try to lock in gcluster failed:  (GBA-02LO-0002) Failed to lock: &#91;testdb.t2580D5F90-B287-4199-B057-E6FBD44B5BFA] GC_AIS_ERR_EXIST\n<\/code><\/pre>\n\n\n\n<p><\/p>","protected":false},"excerpt":{"rendered":"<p>\u5f53\u7531\u4e8e\u67d0\u4e9b\u539f\u56e0\u9700\u8981\u91cd\u5efa\u8868\u65f6\uff0c\u9700\u8981\u9501\u5b9a\u8868\uff0c\u907f\u514d\u8be5\u8868\u5728\u91cd\u5efa\u671f\u95f4\u53c8\u88ab\u66f4\u6539\uff0c\u5bfc\u81f4\u65b0\u8868\u548c\u8001\u8868\u6570\u636e\u4e0d\u4e00\u81f4\u3002\u672c\u6587\u63d0\u4f9b\u4e00\u4e2a\u5e94\u7528\u5c42\u7684\u5b89\u5168\u91cd\u5efa\u65b9\u6848\u3002<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-8310","post","type-post","status-publish","format-standard","hentry","category-gbase8a"],"_links":{"self":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts\/8310","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=8310"}],"version-history":[{"count":17,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts\/8310\/revisions"}],"predecessor-version":[{"id":8662,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts\/8310\/revisions\/8662"}],"wp:attachment":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/media?parent=8310"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/categories?post=8310"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/tags?post=8310"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}