Adds resources to a package so that other projects can access them under controlled permissions.
ADD TO PACKAGE is a CMD statement. Run it on the MaxCompute client (odpscmd).Where this fits in the data-sharing workflow: CREATE PACKAGE → ADD TO PACKAGE → ALLOW PROJECT → INSTALL PACKAGE
Syntax
add <object_type> <object_name> to package <package_name> [with privileges <privileges>];To add all objects of a given type at once, use an asterisk (*) as a wildcard:
add <object_type> * to package <package_name> [with privileges <privileges>];Parameters
| Parameter | Required | Description |
|---|---|---|
object_type | Yes | The type of the object to add. One object type per statement. For supported types, see Permissions. |
object_name | Yes | The name of the object to add. Use plain names only — do not prefix with the project name (for example, use my_table, not project_a.my_table). |
package_name | Yes | The name of the package. Run show packages; on the MaxCompute client to list packages you have created. |
privileges | No | The permissions to grant on the object. Defaults to Read, Describe, and Select. Permissions are bound to the object and cannot be updated later — to change permissions, remove the object and re-add it with the new permissions. For available permissions, see Permissions. |
Look up object names
| Object type | Command |
|---|---|
| Table or view | show tables; |
| Resource file | list resources; |
| Function | list functions; |
| Instance | show instances; |
Limitations
Projects cannot be added to a package.
A package can contain a maximum of 1,000 resources.
Resources are not snapshotted when added. Package users always access the latest version of the data.
Usage notes
Tables and views: Use
add table *to add all tables in the project at once.Resource files: Specify the resource file name without the project prefix. For example, to add
udtf.jar, runadd resource udtf.jar to package <package_name>;.Functions: Functions are added by name. Run
list functions;to confirm the exact name before adding.Instances: Add instances by their instance ID, retrieved with
show instances;.Permissions: If you omit
with privileges, the default permissions (Read, Describe, Select) are applied. Permissions are inseparable from the resource — to grant different permissions on the same resource, remove it first with REMOVE FROM PACKAGE, then re-add it.
Examples
Add a resource file:
add Resource udtf.jar to package datashare;Add a single table:
add Table sale_detail to package datashare;Add all tables at once:
add Table * to package datashare;Add a function:
add Function my_udf to package datashare;What's next
ALLOW PROJECT: Grant another project access to the package.
DISALLOW PROJECT: Revoke a project's access to the package.
REMOVE FROM PACKAGE: Remove resources from the package.
DESCRIBE PACKAGE: View the resources currently in a package.
DROP PACKAGE: Delete a package.
INSTALL PACKAGE: Install the package in another project.
UNINSTALL PACKAGE: Uninstall a package from a project.
GRANT: Grant a user or role access to the package.
REVOKE: Revoke access to the package from a user or role.
SHOW: List packages created or installed in a MaxCompute project.