{"id":13102,"date":"2024-05-28T09:25:23","date_gmt":"2024-05-28T01:25:23","guid":{"rendered":"https:\/\/nj.transwarp.cn:8180\/?p=13102"},"modified":"2024-05-28T09:25:23","modified_gmt":"2024-05-28T01:25:23","slug":"%e7%9c%9f-%c2%b7-%e5%88%97%e7%ba%a7%e6%9d%83%e9%99%90%e6%8e%a7%e5%88%b6","status":"publish","type":"post","link":"https:\/\/kbwp.transwarp.cn\/?p=13102","title":{"rendered":"\u771f \u00b7 \u5217\u7ea7\u6743\u9650\u63a7\u5236"},"content":{"rendered":"<h3>\u6982\u8981\u63cf\u8ff0<\/h3>\n<hr \/>\n<p><strong>&#8211; \u5728\u5f88\u591a\u6570\u636e\u654f\u611f\u884c\u4e1a\uff0c\u9700\u8981\u66f4\u7ec6\u7c92\u5ea6\u7684\u6743\u9650\u63a7\u5236\uff0c\u6bd4\u8f83\u666e\u904d\u7684\u9700\u6c42\u662f \u884c\u7ea7\u6743\u9650\u63a7\u5236 \u548c \u5217\u7ea7\u6743\u9650\u63a7\u5236\u3002\u9ad8\u7248\u672c\u7684Guardian\u670d\u52a1\uff0c\u53ef\u4ee5\u5b9e\u73b0\u754c\u9762\u5316\u914d\u7f6e\u5982\u6b64\u7ec6\u7c92\u5ea6\u7684\u6743\u9650\u7ba1\u63a7\u3002<\/strong><\/p>\n<ul>\n<li>\n<p>\u5982\u94f6\u884c\u6570\u636e\u4ed3\u5e93\uff0c\u64cd\u4f5c\u4eba\u5458\u5728\u67e5\u8be2\u5e26\u6709\u654f\u611f\u4fe1\u606f\u7684\u8868\u65f6\uff0c\u9700\u8981\u5bf9\u654f\u611f\u5b57\u6bb5\u8fdb\u884c\u8131\u654f\u663e\u793a\u3002<\/p>\n<\/li>\n<li>\n<p>\u5982\u94f6\u884c\u6570\u636e\u4ed3\u5e93\uff0c\u64cd\u4f5c\u4eba\u5458\u53ef\u80fd\u5c5e\u4e8e\u4e0d\u540c\u7684\u652f\u884c\uff0c\u4ed6\u4eec\u53ea\u5e94\u8be5\u770b\u5230\u5176\u6240\u5c5e\u652f\u884c\u7684\u6570\u636e\u3002\u6bd4\u8f83\u4f20\u7edf\u7684\u505a\u6cd5\u662f\uff0c\u5c06\u4e00\u5f20\u5927\u8868\u6309\u652f\u884c\u5207\u5206\u6210\u591a\u4e2a\u5c0f\u8868\u6216\u8005\u521b\u5efa\u591a\u4e2aView\uff0c\u4f46\u662f\u8fd9\u79cd\u505a\u6cd5\u5728\u8868\u6216\u8005View\u7684\u7ba1\u7406\u4e0a\u76f8\u5f53\u7e41\u7410\uff0c\u5e76\u4e14\u65e0\u6cd5\u5bf9 update, delete \u64cd\u4f5c\u505a\u884c\u7ea7\u6743\u9650\u63a7\u5236\u3002<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u8fd9\u91cc\uff0c\u6211\u4eec\u5148\u5217\u4e3e\u4e0b \u5217\u6743\u9650\u7684\u884c\u4e3a\uff1a<\/strong><\/p>\n<blockquote>\n<p>\u5982\u679c\u9700\u8981\u5217\u7ea7\u6743\u9650\u63a7\u5236, \u8bf7\u5f00\u542f\u5f00\u5173, \u5f00\u5173\u5fc5\u987b\u5199\u6b7b\u5728<code>hive-site.xml<\/code>\u4e2d, \u5728session\u4e2d\u76f4\u63a5set\u4e0d\u80fd\u751f\u6548:<br \/>\n<code>set inceptor.security.column.authorization.enabled=true;<\/code><\/p>\n<\/blockquote>\n<p>SELECT \/  DESC TABLE \/ SHOW CREATE TABLE \/ SHOW \/ COLUMS FROM TABLE \/ CREATE TABLE AS SELECT<br \/>\n\u8fd9\u5199\u64cd\u4f5c\u90fd\u6d89\u53ca\u5230\u8868\u4e2d\u7684\u6240\u6709\u5217\u6216\u90e8\u5206\u5217, \u884c\u4e3a\u662f:<\/p>\n<ul>\n<li>\u6709\u8868\/\u5e93\u6743\u9650\uff0c \u5c31\u6709\u5168\u90e8\u5217\u6743\u9650<\/li>\n<li>\u6ca1\u6709\u8868\/\u5e93\u6743\u9650\uff0c\u5219\u68c0\u67e5\u5217\u6743\u9650,<br \/>\n\u5bf9\u4e8e\u7b5b\u9009\u6240\u6709\u5217\u7684\u8bed\u53e5(SELECT * FROM tab), \u8fd4\u56de\u6709\u6743\u9650\u7684\u5217.<br \/>\n\u5bf9\u4e8e\u7b5b\u9009\u67d0\u4e9b\u7279\u5b9a\u5217\u7684\u8bed\u53e5(SELECT col1 FROM tab), \u68c0\u67e5\u6240\u6709\u6307\u5b9a\u5217\u7684\u6743\u9650. \u5982\u679c\u7f3a\u5c11\u67d0\u4e00\u4e2a\u5217\u7684\u6743\u9650\u5219\u62a5\u9519.<\/li>\n<\/ul>\n<p>INSERT \/ UPDATE \/ MERGE (\u76ee\u524dMERGE\u662f\u68c0\u67e5INSERT\u6743\u9650)<\/p>\n<ul>\n<li>\u6709\u8868\/\u5e93\u6743\u9650\uff0c \u5c31\u6709\u5168\u90e8\u5217\u6743\u9650<\/li>\n<li>\u6ca1\u6709\u8868\/\u5e93\u6743\u9650\uff0c\u5219\u68c0\u67e5\u5217\u6743\u9650.<\/li>\n<\/ul>\n<p>\u53d6\u6d88\u4e86COLUMN\u4e0a\u7684DELETE\u8fd9\u9879\u6743\u9650<\/p>\n<ul>\n<li>DELETE\u64cd\u4f5c\u90fd\u662f\u5bf9\u4e8e\u6240\u6709\u5217\u7684, \u6240\u4ee5\u68c0\u67e5\u8868\u6743\u9650\u5c31\u597d<\/li>\n<\/ul>\n<p>CREATE TABLE LIKE 0224tab;<\/p>\n<ul>\n<li>\u8fd9\u4e2a\u64cd\u4f5c\u9700\u8981\u8868\u7684\u6743\u9650,\u4e0d\u9700\u8981\u5230\u5217\u7ea7\u522b\u7684\u6743\u9650<\/li>\n<\/ul>\n<h3>\u8be6\u7ec6\u8bf4\u660e<\/h3>\n<hr \/>\n<p><strong>\u4e0b\u9762\u6211\u4eec\u5bf9\u5217\u7ea7\u6743\u9650\u63a7\u5236\u8fdb\u884c\u5177\u4f53\u6d4b\u8bd5\uff1a<\/strong><\/p>\n<ul>\n<li>\u73af\u5883\u51c6\u5907\uff1aArgodb5.2.3<\/li>\n<\/ul>\n<p>Inceptor\u5f00\u542fguardian\u4e4b\u540e\u53ef\u4ee5\u8fdb\u884c\u6743\u9650\u63a7\u5236. TDH7.0\/Argodb2.0\u4e4b\u524d, \u6682\u65f6\u4e0d\u652f\u6301\u5217\u7ea7\u522b\u7684\u6743\u9650\u63a7\u5236. \u672c\u6b21\u6dfb\u52a0\u5bf9\u5217\u7ea7\u522b\u7684\u6743\u9650\u63a7\u5236.<\/p>\n<h4>1. \u6dfb\u52a0\u5168\u5c40\u53c2\u6570 inceptor.security.column.authorization.enabled<\/h4>\n<p>\u5728inceptor\/quark \u53c2\u6570\u9875\u9762\uff0c\u6dfb\u52a0\u81ea\u5b9a\u4e49\u53c2\u6570 <code>inceptor.security.column.authorization.enabled<\/code>\uff0c\u503c\u8bbe\u7f6e\u4e3atrue\uff0c\u914d\u7f6e\u6587\u4ef6\u4e3a<code>hive-site.xml<\/code>\uff0c\u7136\u540e\u914d\u7f6e\u670d\u52a1\uff0c\u91cd\u542f\u670d\u52a1\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/nj.transwarp.cn:8180\/wp-content\/uploads\/2024\/05\/image-1716778404060.png\" alt=\"file\" \/><\/p>\n<h4>2. \u6570\u636e\u51c6\u5907<\/h4>\n<p>\u4f7f\u7528hive\u7528\u6237\u521b\u5efa\u6d4b\u8bd5\u8868\uff0c\u5e76\u63d2\u5165\u6d4b\u8bd5\u6570\u636e\u3002<\/p>\n<pre><code class=\"language-sql\">create database db_col;\nuse db_col;\ndrop table if exists t_col_orc;\ncreate table t_col_orc (id int, name varchar2(20), age varchar2(20)) clustered by (age) into 7 buckets stored as orc_transaction;\ninsert into t_col_orc select 1,\"transwarp\",1 from system.dual;\n\ndrop table if exists t_col_orc1;\ncreate table t_col_orc1 (id int, name varchar2(20), age varchar2(20)) clustered by (age) into 7 buckets stored as orc_transaction;\ninsert into t_col_orc1 select 1,\"transwarp\",2 from system.dual;\ninsert into t_col_orc1 select 1,\"transwarp\",3 from system.dual;<\/code><\/pre>\n<h4>3. \u521b\u5efa\u6d4b\u8bd5\u7528\u6237lkw<\/h4>\n<p>\u6682\u65f6\u4e0d\u8d4b\u4efb\u4f55\u7684\u6743\u9650<\/p>\n<h4>4. \u6d4b\u8bd5SELECT<\/h4>\n<pre><code class=\"language-sql\">[root@kv1~]# beeline -u jdbc:hive2:\/\/172.22.23.2:10000\/default -n lkw -p 123456 --maxWidth=10000 --maxColumnWidth=1000\n...\n0: jdbc:hive2:\/\/172.22.23.2:10000\/default> use db_col;\nNo rows affected (0.335 seconds)\n--\u4e0b\u9762\u7684\u544a\u8b66\u4fe1\u606f\u9700\u8981\u4f18\u5316\n0: jdbc:hive2:\/\/172.22.23.2:10000\/default> select * from t_col_orc; \nError: COMPILE FAILED: Semantic error: [Error 10002] Line 0:0 Invalid column reference. Error encountered near token 'TOK_ALLCOLREF' (state=42000,code=10002)<\/code><\/pre>\n<p>\u5728Guardian\u754c\u9762\u4e0a\u5bf9db_col.t_col_orc.id\u5217\u8d4bSELECT\u6743\u9650\uff0c\u67e5\u8be2\u53ea\u8fd4\u56deid\u5217<\/p>\n<pre><code class=\"language-sql\">0: jdbc:hive2:\/\/172.22.23.2:10000\/default> select * from t_col_orc;\n+-----+\n| id  |\n+-----+\n| 1   |\n+-----+\n1 row selected (8.941 seconds)<\/code><\/pre>\n<h4>5. \u6d4b\u8bd5DESC TABLE<\/h4>\n<p>DESC\u64cd\u4f5c\u9700\u8981\u7684\u4e5f\u662fSELECT\u6743\u9650, \u5c06\u53ea\u4f1a\u8fd4\u56de\u6709\u6743\u9650\u7684\u5217<\/p>\n<pre><code class=\"language-sql\">0: jdbc:hive2:\/\/172.22.23.2:10000\/default> desc t_col_orc;\n+-----------+------------+----------------+-----------+---------+----------+\n| col_name  | data_type  | default_value  | not_null  | unique  | comment  |\n+-----------+------------+----------------+-----------+---------+----------+\n| id        | int        | NULL           | No        | No      |          |\n+-----------+------------+----------------+-----------+---------+----------+\n1 row selected (0.498 seconds)<\/code><\/pre>\n<h4>6. \u6d4b\u8bd5INSERT<\/h4>\n<p>\u5728Guardian\u754c\u9762\u4e0a\u5bf9db_col.t_col_orc.id\u5217\u8d4bINSERT\u6743\u9650<\/p>\n<pre><code class=\"language-sql\">--\u5355\u72ec\u63d2\u5165name\u5217\uff0c\u6210\u529f\n0: jdbc:hive2:\/\/172.22.23.2:10000\/default> insert into t_col_orc (name) values (\"tdh\");\n1 row affected (1.362 seconds)\n--\u5bf9\u5176\u4ed6\u5217\uff0c\u6bd4\u5982age\u5217\u8fdb\u884c\u63d2\u5165\uff0c\u5931\u8d25\n0: jdbc:hive2:\/\/172.22.23.2:10000\/default> insert into t_col_orc (age) values (1);\nError: COMPILE FAILED: Internal error HiveAccessControlException: [Error 20388] Permission denied: Principal [name=lkw, type=USER] does not have following privileges for operation QUERY [[INSERT] on Object [type=COLUMN, name=db_col.t_col_orc[age], action=INSERT]] (state=42000,code=20388)<\/code><\/pre>\n<h4>7. \u6d4b\u8bd5UPDATE<\/h4>\n<p>\u5728Guardian\u754c\u9762\u4e0a\u5bf9db_col.t_col_orc.name \u8d4b\u4e0aUPDATE\u6743\u9650\uff08\u4ee5\u4e0b\u7684sql\u8fd8\u9700\u8981\u786e\u4fddage\u4e0a\u6709SELECT\u6743\u9650\uff09<\/p>\n<pre><code class=\"language-sql\">0: jdbc:hive2:\/\/172.22.23.2:10000\/default> update t_col_orc set name = 5 where age = 1;\n1 row affected (6.463 seconds)\n0: jdbc:hive2:\/\/172.22.23.2:10000\/default> update t_col_orc set name = 1;\n2 rows affected (3.738 seconds)\n0: jdbc:hive2:\/\/172.22.23.2:10000\/default> update t_col_orc set id = 5 where age = 1; \nError: COMPILE FAILED: Internal error HiveAccessControlException: [Error 20388] Permission denied: Principal [name=lkw, type=USER] does not have following privileges for operation QUERY [[UPDATE] on Object [type=COLUMN, name=db_col.t_col_orc[id]]] (state=42000,code=20388)\n0: jdbc:hive2:\/\/172.22.23.2:10000\/default> update t_col_orc t set name = 5 where exists(select 1 from t_col_orc1 t1 where t.id=t1.id);\n1 row affected (4.463 seconds)<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u6982\u8981\u63cf\u8ff0 &#8211; \u5728\u5f88\u591a\u6570\u636e\u654f\u611f\u884c\u4e1a\uff0c\u9700\u8981\u66f4\u7ec6\u7c92\u5ea6\u7684\u6743\u9650\u63a7\u5236\uff0c\u6bd4\u8f83\u666e\u904d\u7684\u9700\u6c42\u662f \u884c\u7ea7\u6743\u9650\u63a7\u5236 \u548c \u5217\u7ea7 ..<\/p>\n<div class=\"clear-fix\"><\/div>\n<p><a href=\"https:\/\/kbwp.transwarp.cn\/?p=13102\" title=\"read more...\">Read more<\/a><\/p>\n","protected":false},"author":12,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[38],"tags":[],"class_list":["post-13102","post","type-post","status-publish","format-standard","hentry","category-configuration"],"acf":[],"_links":{"self":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/13102","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/users\/12"}],"replies":[{"embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=13102"}],"version-history":[{"count":3,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/13102\/revisions"}],"predecessor-version":[{"id":13114,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/13102\/revisions\/13114"}],"wp:attachment":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=13102"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=13102"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=13102"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}