All Products
Search
Document Center

MaxCompute:Grant permissions on federated external tables

Last Updated:Mar 26, 2026

Grant permissions on federated external tables

The creator of an External Schema becomes its owner. Use this topic to grant permissions on an External Schema or its tables to other RAM users.

Important

MaxCompute does not persist data source metadata in Lakehouse mode. Access policies match permissions by data source name. If you rename a data source, all previously granted permissions become invalid. Revoke the old permissions using the REVOKE command or by deleting the access policy before renaming. If you skip this step, a new data source created with the original name may inherit the old permissions and grant unintended access to the original RAM user in an external project.

Important

If Tenant-based Object Authorization is enabled for a project, mount the project on an external data source before creating an External Schema. Otherwise, an error occurs when you create the External Schema.

All examples in this topic use the project test_lakehouse_project.

Permissions reference

The table below shows the permission required for each External Schema operation. Grant permissions using the GRANT command as shown in each section.

Operation Object level Required permissions
Create an External Schema Project CreateSchema; Usage on the foreign server (required only if Tenant-based Object Authorization is enabled)
List all External Schemas Project CreateInstance, List
Describe an External Schema Schema Describe
Modify External Schema properties Not supported
Drop an External Schema Schema Drop
Use an External Schema (three-tier model) None required
Use an External Schema (upgraded from two-tier model) Schema Describe
List tables in an External Schema Schema List
Query a table in an External Schema Table Select
Import data from an External Schema table Table + Project Select on the table; CreateTable, CreateInstance on the project

Create an External Schema

Required permissions: CreateSchema on the project. If Tenant-based Object Authorization is enabled, also Usage on the foreign server.

  1. Set the current project and grant the CreateSchema permission.

    -- Set the current project.
    use test_lakehouse_project;
    
    -- Grant the CreateSchema permission on the project to a RAM user.
    GRANT CreateSchema ON project test_lakehouse_project TO USER RAM$xxx@test.aliyunid.com:test_user;
  2. (Optional) If Tenant-based Object Authorization is enabled and you have mounted an external data source on the project, grant the RAM user permission to use the foreign server.

    -- Add the RAM account provider to the current project.
    ADD accountprovider ram;
    
    -- Add a RAM user.
    ADD USER `RAM$xxx@test.aliyunid.com:test_user`;
    
    -- Create a project role.
    CREATE role test_lakhouse_role;
    
    -- Add an access policy to the role to allow usage of the external data source.
    put policy D:\bin\allow.policy ON role test_lakhouse_role;
    
    -- Grant the role to the RAM user.
    GRANT role test_lakhouse_role TO `RAM$xxx@test.aliyunid.com:test_user`;

    The allow.policy file must contain the following:

    {
      "Version": "1",
      "Statement": [{
        "Action": "odps:Usage",
        "Effect": "Allow",
        "Resource": ["acs:odps:*:servers/fs_hive"]
      }]
    }
  3. Create the External Schema.

    CREATE EXTERNAL SCHEMA IF NOT EXISTS es_hive3
    with fs_hive
    ON 'default' ;

List all External Schemas

Required permissions: CreateInstance and List on the project.

  1. Grant the CreateInstance permission on the project.

    GRANT CreateInstance ON project test_lakehouse_project TO USER RAM$xxx@test.aliyunid.com:test_user;
  2. Grant the List permission on the project.

    GRANT List ON project test_lakehouse_project TO USER RAM$xxx@test.aliyunid.com:test_user;
  3. List all schemas.

    SHOW schemas;

Describe an External Schema

Required permissions: Describe on the schema.

  1. Grant the Describe permission on the schema.

    GRANT DESCRIBE ON SCHEMA es_hive3 TO USER RAM$xxx@test.aliyunid.com:test_user;
  2. Describe the External Schema.

    DESC SCHEMA es_hive3;

Modify External Schema properties

Modifying External Schema properties is not supported.

Drop an External Schema

Required permissions: Drop on the schema.

  1. Grant the Drop permission on the schema.

    GRANT DROP ON SCHEMA es_hive3 TO USER RAM$xxx@test.aliyunid.com:test_user;
  2. Drop the External Schema.

    DROP SCHEMA es_hive3;

Use an External Schema

The required permission depends on how the project was created:

  • Three-tier model (native): No permission required.

  • Upgraded from two-tier to three-tier model: Describe on the schema is required.

Set the current schema to the External Schema.

USE SCHEMA es_hive3;

If the project was upgraded from the two-tier model, grant the Describe permission before running USE SCHEMA.

GRANT DESCRIBE ON SCHEMA es_hive3 TO USER RAM$xxx@test.aliyunid.com:test_user;

List tables in an External Schema

Required permissions: List on the schema.

  1. Grant the List permission on the schema.

    GRANT List ON schema es_hive3 TO USER RAM$xxx@test.aliyunid.com:test_user;
  2. List the tables in the External Schema.

    SHOW tables IN es_hive3;

Query a table in an External Schema

Required permissions: Select on the table.

  1. Grant the Select permission on the table.

    GRANT SELECT ON TABLE es_hive3.t1 TO USER RAM$xxx@test.aliyunid.com:test_user;
  2. Query the table.

    SELECT * FROM es_hive3.t1;

Import data from an External Schema table

Required permissions: Select on the source table; CreateTable and CreateInstance on the project.

  1. Grant the CreateTable permission on the project.

    GRANT CreateTable ON project test_lakehouse_project TO USER RAM$xxx@test.aliyunid.com:test_user;
  2. Grant the CreateInstance permission on the project.

    GRANT CreateInstance ON project test_lakehouse_project TO USER RAM$xxx@test.aliyunid.com:test_user;
  3. Grant the Select permission on the source table.

    GRANT SELECT ON TABLE es_hive3.t1 TO USER RAM$xxx@test.aliyunid.com:test_user;
  4. Import data from the External Schema table into a new managed table.

    CREATE TABLE default.t1_copy_ram3 AS SELECT * FROM t1;