Adds the resources that are required by package users to the package that is created.

Limits

  • You cannot add projects to a package.
  • You can add a maximum of 1,000 resources to a package.
  • When you add resources to a package, the resources are not packaged as snapshots. If resource data is updated after the resources are added to a package, package users access the latest resource data.
  • This statement is a CMD statement and can only be executed on the MaxCompute client (odpscmd).

Syntax

add <object_type> <object_name> to package <package_name> [with privileges <privileges>];

Parameters

Parameter Required Description
object_type Yes The type of the object that you want to add to the package. You can add only one object at a time.

For more information about object types, see Permissions.

object_name Yes The name of the object that you want to add to the package. You can obtain the object name as follows:
  • Table or view name: You can execute the show tables; statement on the MaxCompute client to obtain the table or view name.
  • Resource file name: You can execute the list resources; statement on the MaxCompute client to obtain the resource file name.
  • Function name: You can execute the list functions; statement on the MaxCompute client to obtain the function name.
  • Instance name: You can execute the show instances; statement on the MaxCompute client to obtain the instance name.
Note
  • When you add resources to a package, you can use an asterisk (*) as a regular expression in the statement that is used to add the resources. For example, you can execute the add table * to package package_name; statement to add all tables to a package.
  • When you add resources to a package, do not specify the resource name in the Project name.Resource name format. For example, if you want to add a table named table in Project A to a package, do not specify A.table as the resource name. You must specify table as the resource name.
package_name Yes The name of the package to which you want to add resources.

You can execute the show packages; statement on the MaxCompute client to obtain the information about the package that you created.

privileges No The operation permissions on resources in the package. If you do not specify this parameter, the Read, Describe, and Select permissions on the resources are added to the package by default. The resources and operation permissions on the resources are inseparable and cannot be updated after you add them to a package. If you want to update the resources or operation permissions on these resources in a package, you must delete the resources from the package and then add the updated resources and operation permissions on the resources to the package again.

For more information about operation permissions, see Permissions.

Examples

Add the resource file udtf.jar and the tables sale_detail and bank_data of the test_project_a project to the package that you created. Sample statements:
-- Add resources to the package that you created. 
add Resource udtf.jar to package datashare;
add Table sale_detail to package datashare;

Related statements

  • CREATE PACKAGE: Creates a package.
  • REMOVE FROM PACKAGE: Removes resources from the package that is created.
  • ALLOW PROJECT: A package creator in a project authorizes other projects to use the package that is created.
  • DISALLOW PROJECT: A package creator revokes access permissions on a package from a project.
  • DESCRIBE PACKAGE: Views the details of a package that is created in a MaxCompute project.
  • DROP PACKAGE: Deletes a package.
  • INSTALL PACKAGE: Installs a package in a MaxCompute project.
  • UNINSTALL PACKAGE: Uninstalls a package that is installed from a MaxCompute project.
  • GRANT: Authorizes a user or role to access a package.
  • REVOKE: Revokes access permissions on a package from a user or role.
  • SHOW: Views the packages that are created or installed in a MaxCompute project.