全部產品
Search
文件中心

MaxCompute:許可權命令集

更新時間:Sep 17, 2026

本文介紹MaxCompute專案中的許可權管理命令全集,包含使用者管理、角色管理、使用者或角色授權、許可權查看等命令。

角色管理

使用者管理

角色授權

為角色授予對象的操作許可權

  • 為角色授予專案的操作許可權

    • 命令

      • ACL授權

        GRANT Read|Write|List|CreateTable|CreateInstance|CreateFunction|CreateResource|All 
              ON project <project_name> 
              TO ROLE <role_name> [privilegeproperties("conditions" = "<conditions>", "expires"="<days>")];
      • 通過ACL文法實現Policy授權

        GRANT Read|Write|List|CreateTable|CreateInstance|CreateFunction|CreateResource|All 
              ON project <project_name> 
              TO ROLE <role_name> privilegeproperties("policy" = "true", "{allow}"="{true|false}"[, "conditions"= "<conditions>", "expires"="<days>"]);
    • 樣本

      --ACL授權。
      grant CreateTable, CreateFunction, CreateInstance, List on project test_project_a to ROLE Worker;
      --Policy授權。
      grant CreateTable, CreateFunction, CreateInstance, List 
            on project test_project_a  
            to ROLE Worker privilegeproperties("policy" = "true", "allow"="true");
  • 為角色授予表的操作許可權

    • 命令

      • ACL授權

        GRANT Describe|Select|Alter|Update|Drop|ShowHistory|All 
              ON TABLE <table_name> [(<column_list>)] 
              TO ROLE <role_name> [privilegeproperties("conditions" = "<conditions>", "expires"="<days>")];
      • 通過ACL文法實現Policy授權

        GRANT Describe|Select|Alter|Update|Drop|ShowHistory|All 
              ON TABLE <table_name> [(<column_list>)] 
              TO ROLE <role_name> privilegeproperties("policy" = "true", "{allow}"="{true|false}"[, "conditions"= "<conditions>", "expires"="<days>"]);
    • 樣本

      --ACL授權。
      grant Describe, Select on table sale_detail to ROLE Worker;
      --Policy授權。
      grant Describe, Select  
            on table sale_detail   
            to ROLE Worker privilegeproperties("policy" = "true", "allow"="true");
  • 為角色授予模型的操作許可權

    • 命令

      • ACL授權

        GRANT Describe|Execute|Alter|Drop|All 
              ON MODEL <model_name> 
              TO ROLE <role_name> [privilegeproperties("conditions" = "<conditions>", "expires"="<days>")];
      • 通過ACL文法實現Policy授權

        GRANT Describe|Execute|Alter|Drop|All 
              ON MODEL <model_name> 
              TO ROLE <role_name> privilegeproperties("policy" = "true", "{allow}"="{true|false}"[, "conditions"= "<conditions>", "expires"="<days>"]);
    • 樣本

      -- Bob進入test_project_a專案。
      use test_project_a;
      -- ACL授權。
      GRANT All ON MODEL my_model TO ROLE Worker;
      -- 通過ACL文法實現Policy授權。
      GRANT All  
            ON MODEL my_model  
            TO ROLE Worker privilegeproperties("policy" = "true", "allow"="true");
  • 為角色授予資源的操作許可權

    • 命令

      • ACL授權

        GRANT Read|Write|Delete|All 
              ON resource <resource_name> 
              TO ROLE <role_name> [privilegeproperties("conditions" = "<conditions>", "expires"="<days>")];
      • 通過ACL文法實現Policy授權

        GRANT Read|Write|Delete|All 
              ON resource <resource_name> 
              TO ROLE <role_name> privilegeproperties("policy" = "true", "{allow}"="{true|false}"[, "conditions"= "<conditions>", "expires"="<days>"]);
    • 樣本

      --ACL授權。
      grant Read, Write on resource udtf.jar to ROLE Worker;
      --Policy授權。
      grant Read, Write   
            on resource udtf.jar  
            to ROLE Worker privilegeproperties("policy" = "true", "allow"="true");
  • 為角色授予函數的操作許可權

    • 命令

      GRANT Read|Write|Delete|Execute|All 
            ON FUNCTION <function_name> 
            TO ROLE <role_name> [privilegeproperties("conditions" = "<conditions>", "expires"="<days>")];
    • 樣本

      --ACL授權。
      grant Read, Write on function udf_test to ROLE Worker;
      --Policy授權。
      grant Read, Write   
            on function udf_test  
            to ROLE Worker privilegeproperties("policy" = "true", "allow"="true");
  • 為角色授予執行個體的操作許可權

    • 命令

      • ACL授權

        GRANT Read|Write|All 
              ON instance <instance_id> 
              TO ROLE <role_name> [privilegeproperties("conditions" = "<conditions>", "expires"="<days>")];
      • 通過ACL文法實現Policy授權

        GRANT Read|Write|All  
              ON instance <instance_id>   
              TO ROLE <role_name> privilegeproperties("policy" = "true", "{allow}"="{true|false}"[, "conditions"= "<conditions>", "expires"="<days>"]);
    • 樣本

      --ACL授權。
      grant All on instance 202112300224**** to ROLE Worker;
      --Policy授權。
      grant All    
            on instance 202112300224****   
            to ROLE Worker privilegeproperties("policy" = "true", "allow"="true");

撤銷為角色授予的對象的操作許可權

  • 撤銷為角色授予的專案操作許可權

    • 命令

      • 撤銷ACL授權

        REVOKE Read|Write|List|CreateTable|CreateInstance|CreateFunction|CreateResource|All 
              ON project <project_name> 
              FROM ROLE <role_name>;
      • 撤銷Policy授權

        REVOKE Read|Write|List|CreateTable|CreateInstance|CreateFunction|CreateResource|All 
              ON project <project_name> 
              FROM ROLE <role_name> privilegeproperties("policy" = "true", "{allow}"="{true|false}");
    • 樣本

      --撤銷ACL授權。
      revoke CreateTable, CreateFunction, CreateInstance, List on project test_project_a from ROLE Worker;
      --撤銷Policy授權。
      revoke CreateTable, CreateFunction, CreateInstance, List 
            on project test_project_a  
            from ROLE Worker privilegeproperties("policy" = "true", "allow"="true");
  • 撤銷為角色授予的表操作許可權

    • 命令

      • 撤銷ACL授權

        REVOKE Describe|Select|Alter|Update|Drop|ShowHistory|All 
              ON TABLE <table_name> [(<column_list>)] 
              FROM ROLE <role_name>;
      • 撤銷Policy授權

        REVOKE Describe|Select|Alter|Update|Drop|ShowHistory|All 
              ON TABLE <table_name> [(<column_list>)] 
              FROM ROLE <role_name> privilegeproperties("policy" = "true", "{allow}"="{true|false}");
    • 樣本

      --撤銷ACL授權。
      revoke Describe, Select on table sale_detail from ROLE Worker;
      --撤銷Policy授權。
      revoke Describe, Select  
            on table sale_detail   
            from ROLE Worker privilegeproperties("policy" = "true", "allow"="true");
  • 撤銷為角色授予的模型的操作許可權

    • 命令

      • 撤銷ACL授權

        REVOKE Describe|Execute|Alter|Drop|All 
              ON MODEL <model_name>
              FROM ROLE <role_name>;
      • 撤銷Policy授權

        REVOKE Describe|Execute|Alter|Drop|All 
              ON MODEL <model_name> 
              FROM ROLE <role_name> privilegeproperties("policy" = "true", "{allow}"="{true|false}");
    • 樣本

      -- Bob進入test_project_a專案。
      use test_project_a;
      -- 撤銷ACL授權。
      REVOKE All ON MODEL my_model FROM ROLE Worker;
      -- 撤銷Policy授權。
      REVOKE All  
            ON MODEL my_model  
            FROM ROLE Worker privilegeproperties("policy" = "true", "allow"="true");
  • 撤銷為角色授予的資源操作許可權

    • 命令

      • 撤銷ACL授權

        REVOKE Read|Write|Delete|All 
              ON resource <resource_name> 
              FROM ROLE <role_name>;
      • 撤銷Policy授權

        REVOKE Read|Write|Delete|All 
              ON resource <resource_name> 
              FROM ROLE <role_name> privilegeproperties("policy" = "true", "{allow}"="{true|false}");
    • 樣本

      --撤銷ACL授權。
      revoke Read, Write on resource udtf.jar from ROLE Worker;
      --撤銷Policy授權。
      revoke Read, Write   
            on resource udtf.jar  
            from ROLE Worker privilegeproperties("policy" = "true", "allow"="true");
  • 撤銷為角色授予的函數操作許可權

    • 命令

      • 撤銷ACL授權

        REVOKE Read|Write|Delete|Execute|All 
              ON FUNCTION <function_name> 
              FROM ROLE <role_name>;
      • 撤銷Policy授權

        REVOKE Read|Write|Delete|Execute|All 
              ON FUNCTION <function_name>  
              FROM ROLE <role_name> privilegeproperties("policy" = "true", "{allow}"="{true|false}");
    • 樣本

      --撤銷ACL授權。
      revoke Read, Write on function udf_test from ROLE Worker;
      --撤銷Policy授權。
      revoke Read, Write   
            on function udf_test  
            from ROLE Worker privilegeproperties("policy" = "true", "allow"="true");
  • 撤銷為角色授予的執行個體操作許可權

    • 命令

      REVOKE Read|Write|All  
            ON instance <instance_id>   
            FROM ROLE <role_name> privilegeproperties("policy" = "true", "{allow}"="{true|false}");
    • 樣本

      --撤銷ACL授權。
      revoke All on instance 202112300224**** from ROLE Worker;
      --撤銷Policy授權。
      revoke All    
            on instance 202112300224****   
            from ROLE Worker privilegeproperties("policy" = "true", "allow"="true");

為角色授予Download許可權

  • 命令

    GRANT Download ON {Table|Resource|Function|Instance} <object_name> TO ROLE <role_name>;
  • 樣本

    grant download on table sale_detail to ROLE Worker;

撤銷為角色授予的Download許可權

  • 命令

    REVOKE Download ON {Table|Resource|Function|Instance} <object_name> FROM ROLE <role_name>;
  • 樣本

    revoke download on table sale_detail from ROLE Worker;

為角色授予訪問高敏感等級資料的許可權

  • 命令

    GRANT Label <number> ON TABLE <table_name> [(<column_list>)] TO ROLE <role_name> [WITH exp <days>];
  • 樣本

    grant Label 4 on table sale_detail to ROLE Worker;

撤銷為角色授予的訪問高敏感等級資料的許可權

  • 命令

    REVOKE Label ON TABLE <table_name> [(<column_list>)] FROM ROLE <role_name>;
  • 樣本

    revoke Label on table sale_detail from ROLE Worker;

將角色賦予使用者

  • 命令

    GRANT <role_name> TO <user_name>;
  • 樣本

    grant Worker to ALIYUN$Ka**@aliyun.com;
    grant Worker to RAM$Bo*@aliyun.com:Allen;

收回賦予使用者的角色

  • 命令

    REVOKE <role_name> FROM <user_name>;
  • 樣本

    revoke Worker from ALIYUN$Ka**@aliyun.com;
    revoke Worker from RAM$Bo*@aliyun.com:Allen;

使用者授權

為使用者賦予操作許可權

  • 為使用者授予專案的操作許可權

    • 命令

      grant Read|Write|List|CreateTable|CreateInstance|CreateFunction|CreateResource|All
            on project <project_name>
            to USER <user_name> [privilegeproperties("conditions" = "<conditions>",
    • 樣本

      grant CreateTable, CreateFunction, CreateInstance, List on project test_project_a to user RAM$Ka**@aliyun.com:Lily;
  • 為使用者授予表的操作許可權

    • 命令

      grant Describe|Select|Alter|Update|Drop|ShowHistory|All
            on table <table_name> [(<column_list>)]
            to USER <user_name> [privilegeproperties("conditions" = "<conditions>"
    • 樣本

      grant Describe, Select on table sale_detail to USER RAM$Bo*@aliyun.com:Allen;
  • 為使用者授予資源的操作許可權

    • 命令

      grant Read|Write|Delete|All
            on resource <resource_name>
            to USER <user_name> [privilegeproperties("conditions" = "<conditions>",
    • 樣本

      grant Read, Write on resource udtf.jar to USER RAM$Bo*@aliyun.com:Alice;
  • 為使用者授予函數的操作許可權

    • 命令

      grant Read|Write|Delete|Execute|All
            on function <function_name>
            to USER <user_name> [privilegeproperties("conditions" = "<conditions>"
    • 樣本

      grant Read, Write on function udf_test to USER RAM$Bo*@aliyun.com:Tom;
  • 為使用者授予執行個體的操作許可權

    • 命令

      grant Read|Write|All
            on instance <instance_id>
            to USER <user_name> [privilegeproperties("conditions" = "<conditions>"
    • 樣本

      grant All on instance 202112300224**** to USER RAM$Bo*@aliyun.com:Tom;

撤銷使用者操作許可權

  • 撤銷為使用者授予的專案的操作許可權

    • 命令

      revoke Read|Write|List|CreateTable|CreateInstance|CreateFunction|CreateResource|All
            on project <project_name>
            from USER <user_name>;
    • 樣本

      revoke CreateTable, CreateFunction, CreateInstance, List on project test_project_a from user RAM$Ka**@aliyun.com:Lily;
  • 撤銷為使用者授予的表的操作許可權

    • 命令

      revoke Describe|Select|Alter|Update|Drop|ShowHistory|All
            on table <table_name> [(<column_list>)]
            from USER <user_name>;
    • 樣本

      revoke Describe, Select on table sale_detail from USER RAM$Bo*@aliyun.com:Allen;
  • 撤銷為使用者授予的資源的操作許可權

    • 命令

      revoke Read|Write|Delete|All
            on resource <resource_name>
            from USER <user_name>;
    • 樣本

      revoke Read, Write on resource udtf.jar from USER RAM$Bo*@aliyun.com:Alice;
  • 撤銷為使用者授予的函數的操作許可權

    • 命令

      revoke Read|Write|Delete|Execute|All
            on function <function_name>
            from USER <user_name>;
    • 樣本

      revoke Read, Write on function udf_test from USER RAM$Bo*@aliyun.com:Tom;
  • 撤銷為使用者授予的執行個體的操作許可權

    • 命令

      revoke Read|Write|All
            on instance <instance_id>
            from USER <user_name>;
    • 樣本

      revoke All on instance 202112300224**** from USER RAM$Bo*@aliyun.com:Tom;

為角色授予對象的操作許可權並將角色賦予使用者

--為角色Worker授權。
   --ACL授權。
grant CreateTable, CreateFunction, CreateInstance, List on project test_project_a to ROLE Worker;
   --Policy授權。
grant CreateTable, CreateFunction, CreateInstance, List 
      on project test_project_a  
      to ROLE Worker privilegeproperties("policy" = "true", "allow"="true");
--將角色Worker賦予使用者。
grant Worker to RAM$Bo*@aliyun.com:Allen;
grant Worker to RAM$Bo*@aliyun.com:Alice;
grant Worker to RAM$Bob@aliyun.com:Tom;

撤銷為角色授予的對象的操作許可權或收回賦予使用者的角色

--為角色Worker撤銷授權。
   --撤銷ACL授權。
revoke CreateTable, CreateFunction, CreateInstance, List on project test_project_a from ROLE Worker;
   --撤銷Policy授權。
revoke CreateTable, CreateFunction, CreateInstance, List 
      on project test_project_a  
      from ROLE Worker privilegeproperties("policy" = "true", "allow"="true");
--或
--收回賦予使用者的角色Worker。
revoke Worker from RAM$Bo*@aliyun.com:Allen;

為使用者授予Download許可權

  • 命令

    grant Download on {Table|Resource|Function|Instance} <object_name> to USER <user_name>;
  • 樣本

    grant Download on table sale_detail to USER RAM$Bo*@aliyun.com:Allen;

收回為使用者授予的Download許可權

  • 命令

    revoke Download on {Table|Resource|Function|Instance} <object_name> from USER <user_name>;
  • 樣本

    revoke Download on table sale_detail from USER RAM$Bo*@aliyun.com:Allen;

為角色授予Download許可權並將角色賦予使用者

--建立角色Worker。
create role Worker;
--為角色Worker授權。
grant download on table sale_detail to ROLE Worker;
--將角色Worker賦予使用者。
grant Worker to RAM$Bo*@aliyun.com:Allen;
grant Worker to RAM$Bo*@aliyun.com:Alice;
grant Worker to RAM$Bob@aliyun.com:Tom;

撤銷為角色授予的Download許可權或收回賦予使用者的角色

-為角色Worker撤銷授權。
revoke download on table sale_detail from ROLE Worker;
--或
--收回賦予使用者的角色Worker。
revoke Worker from RAM$Bo*@aliyun.com:Allen;

為使用者授予訪問高敏感等級資料的許可權

  • 命令

    grant Label <number> on table <table_name> [(<column_list>)] to USER <user_name> [with exp <days>];
  • 樣本

    grant Label 4 on table sale_detail to USER RAM$Bo*@aliyun.com:Allen;

撤銷為使用者授予的訪問高敏感等級資料的許可權

  • 命令

    revoke Label on table <table_name> [(<column_list>)] from USER <user_name>;
  • 樣本

    revoke Label on table sale_detail from ROLE Worker;

為角色授予訪問高敏感等級資料的許可權並將角色賦予使用者

--建立角色Worker。
create role Worker;
--為角色Worker授權。
grant Label 4 on table * to ROLE Worker;
--將角色Worker賦予使用者。
grant Worker to RAM$Bo*@aliyun.com:Allen;
grant Worker to RAM$Bo*@aliyun.com:Alice;
grant Worker to RAM$Bob@aliyun.com:Tom;

撤銷為角色授予的訪問高敏感等級資料的許可權或收回賦予使用者的角色

-為角色Worker撤銷授權。
revoke Label on table * from ROLE Worker;
--或
--收回賦予使用者的角色Worker。
revoke Worker from RAM$Bo*@aliyun.com:Allen;

徹底清除被刪除使用者遺留的許可權資訊

  • 命令

    purge privs from user <user_name>;
  • 樣本

    purge privs from user RAM$Bo*@aliyun.com:Allen;

查詢許可權資訊

查詢指定角色的許可權及綁定的使用者資訊

查詢指定角色的許可權及綁定的使用者資訊詳情請參見查詢指定角色的許可權及綁定的使用者資訊。

  • 命令

    describe role <role_name>;
  • 樣本

    describe role Worker;

查詢使用者的許可權資訊

查詢對象的ACL授權資訊

查詢對象的ACL授權資訊詳情請參見查詢指定對象的ACL授權資訊。

  • 命令

    show acl for <object_name> [on type <object_type>];
  • 樣本

    show acl for test_project_a on type project;

查詢Label許可權資訊

查詢Package授權資訊

  • 查詢指定Package的授權資訊

    • 命令

      show acl for <project_name>.<package_name> on type package;
    • 樣本

      show acl for test_project_b.datashare on type package;
  • 查詢指定Package內資源的授權資訊

    • 命令

      show grants on <object_type> <object_name> privilegeproperties ("refobject"="true", "refproject"="<project_name>", "package"="<package
      _name>");
    • 樣本

      show grants on Table sale_detail privilegeproperties ("refobject"="true", "refproject"="test_project_a", "package"="datashare");
  • 查詢指定Package內表的Label授權資訊

    • 命令

      show label grants on table <table_name> privilegeproperties ("refobject"="true", "refproject"="<project_name>", "package"="<package_name>");
    • 樣本

      show label grants on table sale_detail privilegeproperties ("refobject"="true", "refproject"="test_project_a", "package"="datashare");

查看專案空間安全配置資訊

  • 專案空間資料保護

    • 開啟或關閉專案空間資料保護機制

      set ProjectProtection=true|false;
    • 查看專案空間的安全配置

      show SecurityConfiguration;

      返回結果中有ProjectProtection=true|false,對應專案空間資料保護機制已開啟或關閉。

  • 查看已添加的可信的專案空間

    list trustedprojects;
  • LabelSecurity許可權控制策略

    • 開啟或關閉LabelSecurity許可權控制策略

      set LabelSecurity=true|false;
    • 查看專案空間的安全配置

      show SecurityConfiguration;

      返回結果中有LabelSecurity=true|false,對應專案空間LabelSecurity許可權控制策略已開啟或關閉。

  • Download許可權控制功能

    • 開啟或關閉Download許可權控制功能

      setproject odps.security.enabledownloadprivilege=true|false;
    • 查看專案空間屬性

      setproject;

      返回結果中有odps.security.enabledownloadprivilege = true|false,對應專案空間Download許可權控制功能已開啟或關閉。