[TOC] # REVOKE ## 描述 该语句用于系统管理员撤销 User 的某些权限。 使用说明如下: * 用户必须拥有被撤销的权限(例如,user1 要撤销 user2 对表 t1 的 SELECT 权限,则 user1 必须拥有表 t1 的 SELECT的权限),并且拥有 GRANT OPTION权限。 * 撤销 ALL PRIVILEGES 和 GRANT OPTION 权限时,当前用户必须拥有全局 GRANT OPTION 权限,或者对权限表的UPDATE 及 DELETE 权限。 * 撤销操作不会级联。例如,用户 user1 给 user2 授予了某些权限,撤回 user1 的权限不会同时也撤回 user2 的相应权限。 ## 格式 ~~~ REVOKE priv_type      ON database.tblname      FROM 'username'; privilege_type: ALTER | CREATE | CREATE USER | CREATE VIEW | DELETE | DROP | GRANT OPTION | INDEX | INSERT | PROCESS | SELECT | SHOW DATABASES | SHOW VIEW | SUPER | UPDATE | USAGE ~~~ ## 参数解释 <table data-tag="table" id="table-pru-1yx-n3m" class="table"><colgroup width="185" span="1" data-tag="col" id="col-pdt-t5z-zyh" colwidth="1*" colnum="1" colname="col1" style="width:50%" class="col"></colgroup><colgroup width="517" span="1" data-tag="col" id="col-hn2-7o3-862" colwidth="1*" colnum="2" colname="col2" style="width:50%" class="col"></colgroup><thead id="thead-h1q-3c6-tol" class="thead"><tr id="tr-1c0-j3q-w6a"><th id="td-5yl-k2d-1o4"><p id="p-k15-32u-gg0"><b>参数</b></p></th><th id="td-1s1-qo6-mhw"><p id="p-x07-8h7-aph"><b>描述</b></p></th></tr></thead><tbody data-tag="tbody" id="tbody-9zm-8eo-gna" class="tbody"><tr data-tag="tr" id="tr-erv-21d-91q" class="tr"><td data-tag="td" id="td-nx8-tch-vp6" class="td"><p data-tag="p" id="p-u0z-cbh-d2b" class="p">priv_type</p></td><td data-tag="td" id="td-ygd-5fy-ik4" class="td"><p data-tag="p" id="p-uf0-20a-dc9" class="p">指定撤销的权限类型。具体的权限类型及其说明请参见下方权限类型说明表。</p><p data-tag="p" id="p-3xf-znk-ozg" class="p">同时对某个用户撤销多个权限时,权限类型用“,”隔开。</p></td></tr><tr data-tag="tr" id="tr-q4i-zf8-xh0" class="tr"><td data-tag="td" id="td-5db-9oc-415" class="td"><p id="p-25o-n3b-ydf">database.tblname </p></td><td data-tag="td" id="td-r7v-99g-bku" class="td"><p data-tag="p" id="p-1h1-npc-p9p" class="p">指定数据库中的表。</p><p data-tag="p" id="p-yjs-vrl-0l4" class="p"><span data-mce-style="font-size: 11px" data-tag="span" id="span-4gv-8f4-fs3" class="span">用“*”代替 database 或 </span><span data-mce-style="font-size: 11px" data-tag="span" id="span-4gv-8f4-fs3" class="span"><em data-tag="em" id="em-d74-v47-fqt" class="em">table_name</em></span><span data-mce-style="font-size: 11px" data-tag="span" id="span-4gv-8f4-fs3" class="span">,表示撤销全局权限,即撤销对数据库中所有表的操作权限。</span></p></td></tr><tr data-tag="tr" id="tr-i18-r8e-p06" class="tr"><td data-tag="td" id="td-6il-y6h-ipm" class="td"><p data-tag="p" id="p-ubx-7dd-q7o" class="p">username</p></td><td data-tag="td" id="td-zid-ykl-epv" class="td"><p data-tag="p" id="p-3dv-giq-mvj" class="p">指定撤销权限的用户。同时撤销多个用户的授权时,用户名用“,”隔开。</p></td></tr></tbody></table> 可以撤销的权限类型如下表所示。 **权限类型说明表** <table data-tag="table" id="table-45o-qm4-vfz" class="table"><colgroup span="1" width="204" data-tag="col" id="col-4ym-co1-s37" colwidth="1*" colnum="1" colname="col1" style="width:50%" class="col"></colgroup><colgroup span="1" width="374" data-tag="col" id="col-3x2-blp-wxf" colwidth="1*" colnum="2" colname="col2" style="width:50%" class="col"></colgroup><thead id="thead-xb8-s0d-yce" class="thead"><tr id="tr-vi7-xbl-cqg"><th id="td-i3u-uqv-nzr"><p id="p-tuj-w3p-hu2"><b>权限</b></p></th><th id="td-8cd-i6t-ivd"><p id="p-592-ctt-620"><b>说明</b></p></th></tr></thead><tbody data-tag="tbody" id="tbody-xr6-ez7-v6p" class="tbody"><tr data-tag="tr" id="tr-yu6-yog-nig" class="tr"><td data-tag="td" id="td-clx-j8a-2p3" class="td"><p data-tag="p" id="p-nvz-kp3-hex" class="p">ALL PRIVILEGES</p></td><td data-tag="td" id="td-8ov-dre-pfq" class="td"><p data-tag="p" id="p-hy1-69a-6hg" class="p">除GRANT OPTION以外所有权限。</p></td></tr><tr data-tag="tr" id="tr-t0v-ycy-lox" class="tr"><td data-tag="td" id="td-r1q-vmu-db0" class="td"><p data-tag="p" id="p-c18-exu-xd9" class="p">ALTER</p></td><td data-tag="td" id="td-466-zi2-c46" class="td"><p data-tag="p" id="p-7f3-pv1-8h1" class="p">ALTER TABLE的权限。</p></td></tr><tr data-tag="tr" id="tr-zkt-7fd-i2e" class="tr"><td data-tag="td" id="td-l5a-38g-mnl" class="td"><p data-tag="p" id="p-zn6-lnk-l9a" class="p">CREATE</p></td><td data-tag="td" id="td-476-2wv-o0p" class="td"><p data-tag="p" id="p-6oa-i9o-93n" class="p">CREATE TABLE的权限。</p></td></tr><tr data-tag="tr" id="tr-o6z-ugp-nxz" class="tr"><td data-tag="td" id="td-7tw-t77-ji3" class="td"><p data-tag="p" id="p-ykx-cae-68l" class="p">CREATE USER</p></td><td data-tag="td" id="td-4wr-u4t-tjr" class="td"><p data-tag="p" id="p-7kd-ivh-0mu" class="p">CREATE USER,DROP USER,RENAME USER和REVOKE ALL PRIVILEGES的权限。</p></td></tr><tr data-tag="tr" id="tr-oy3-y9p-0h8" class="tr"><td data-tag="td" id="td-gjo-dci-7bt" class="td"><p data-tag="p" id="p-jiy-c2g-5d8" class="p">CREATE TABLEGROUP</p></td><td data-tag="td" id="td-v3o-if8-fee" class="td"><p data-tag="p" id="p-d2v-mij-lzl" class="p">全局CREATE TABLEGROUP的权限。</p></td></tr><tr data-tag="tr" id="tr-n2p-ck9-iwx" class="tr"><td data-tag="td" id="td-qsb-dsm-x94" class="td"><p data-tag="p" id="p-bgc-owe-p4c" class="p">DELETE</p></td><td data-tag="td" id="td-d88-dlu-syd" class="td"><p data-tag="p" id="p-o92-t6i-776" class="p">DELETE的权限。</p></td></tr><tr data-tag="tr" id="tr-zbi-f75-6p5" class="tr"><td data-tag="td" id="td-dcv-aax-qnc" class="td"><p data-tag="p" id="p-ofj-ar8-shm" class="p">DROP</p></td><td data-tag="td" id="td-qmf-0s2-j8c" class="td"><p data-tag="p" id="p-n92-9nx-yhr" class="p">DROP的权限。</p></td></tr><tr data-tag="tr" id="tr-5ws-2dj-whh" class="tr"><td data-tag="td" id="td-5ls-q4u-8x3" class="td"><p data-tag="p" id="p-crl-yzm-tpu" class="p">GRANT OPTION</p></td><td data-tag="td" id="td-n71-9w4-sxs" class="td"><p data-tag="p" id="p-x0t-wb3-fux" class="p">GRANT OPTION的权限。</p></td></tr><tr data-tag="tr" id="tr-9n2-6mn-l6c" class="tr"><td data-tag="td" id="td-2ks-12r-b24" class="td"><p data-tag="p" id="p-wvc-737-krz" class="p">INSERT</p></td><td data-tag="td" id="td-s83-mga-952" class="td"><p data-tag="p" id="p-kzp-ebv-q2j" class="p">INSERT的权限。</p></td></tr><tr data-tag="tr" id="tr-x5n-r2t-t0v" class="tr"><td data-tag="td" id="td-24t-i85-qdt" class="td"><p data-tag="p" id="p-msh-ww8-jmo" class="p">SELECT</p></td><td data-tag="td" id="td-g4z-5i8-zj2" class="td"><p data-tag="p" id="p-wg2-k1h-wpw" class="p">SELECT的权限。</p></td></tr><tr data-tag="tr" id="tr-pva-1f9-yln" class="tr"><td data-tag="td" id="td-195-8ah-bcj" class="td"><p data-tag="p" id="p-mtx-dke-wr0" class="p">UPDATE</p></td><td data-tag="td" id="td-afb-prt-2pq" class="td"><p data-tag="p" id="p-xk2-kjn-azm" class="p">UPDATE的权限。</p></td></tr><tr data-tag="tr" id="tr-z3n-oye-qgb" class="tr"><td data-tag="td" id="td-eck-q3v-8ah" class="td"><p data-tag="p" id="p-qox-1v9-dgl" class="p">SUPER</p></td><td data-tag="td" id="td-f92-gqr-zgt" class="td"><p data-tag="p" id="p-uil-56o-erd" class="p">SET GLOBAL修改全局系统参数的权限。</p></td></tr><tr data-tag="tr" id="tr-ghf-0j4-1nq" class="tr"><td data-tag="td" id="td-8w9-x8o-heh" class="td"><p data-tag="p" id="p-e8a-ijm-hra" class="p">SHOW DATABASES</p></td><td data-tag="td" id="td-smm-bot-nka" class="td"><p data-tag="p" id="p-vl6-f0d-set" class="p">全局 SHOW DATABASES的权限。</p></td></tr><tr data-tag="tr" id="tr-21k-eer-kk7" class="tr"><td data-tag="td" id="td-iol-14l-o0w" class="td"><p data-tag="p" id="p-vaz-1ze-xma" class="p">INDEX</p></td><td data-tag="td" id="td-xby-afd-7bw" class="td"><p data-tag="p" id="p-8xl-ssa-kyh" class="p">CREATE INDEX, DROP INDEX的权限。</p></td></tr><tr data-tag="tr" id="tr-12d-qgu-2ed" class="tr"><td data-tag="td" id="td-typ-fcf-1km" class="td"><p data-tag="p" id="p-hd5-52u-auc" class="p">CREATE VIEW</p></td><td data-tag="td" id="td-y1f-bl6-4hk" class="td"><p data-tag="p" id="p-tug-lg9-i4d" class="p">创建、删除视图的权限。</p></td></tr><tr data-tag="tr" id="tr-yeq-c6q-emo" class="tr"><td data-tag="td" id="td-xyc-0bc-m6e" class="td"><p data-tag="p" id="p-uxy-9h6-884" class="p">SHOW VIEW</p></td><td data-tag="td" id="td-fps-zxn-qn2" class="td"><p data-tag="p" id="p-ax2-qbf-o8f" class="p">SHOW CREATE VIEW权限。</p></td></tr><tr data-tag="tr" id="tr-f5j-l7c-goh" class="tr"><td data-tag="td" id="td-1qa-9wl-0h8" class="td"><p data-tag="p" id="p-iel-ogj-ay5" class="p">CREATE SYNONYM</p></td><td data-tag="td" id="td-l5q-3f8-i4w" class="td"><p data-tag="p" id="p-m6g-ilo-qx5" class="p">创建同义词的权限。</p></td></tr></tbody></table> **明** 目前没有change effective tenant 的权限控制,故 sys 租户下的用户都可以撤销权限。 ## 示例 执行以下命令撤销用户 obsqluser01 的所有权限。 ~~~ OceanBase(admin@TEST)>REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'obsqluser01'; Query OK, 0 rows affected (0.03 sec) ~~~