All Products
Search
Document Center

MaxCompute:ADD TABLE

Last Updated:Mar 26, 2026

Registers a MaxCompute table as a resource so that SQL and MapReduce jobs can reference it at runtime.

This is a CMD statement. Run it on the MaxCompute client (odpscmd) only.

Limitations

  • External tables cannot be added as resources.

  • Schema evolution is not supported for tables registered as resources. If a table undergoes schema evolution after being added, remove it and add it again.

  • Each resource file cannot exceed 2,048 MB.

  • The total size of resources referenced by a single SQL or MapReduce job cannot exceed 2,048 MB.

Syntax

add table <table_name> [partition (<spec>)] [as <alias>] [comment '<comment>'] [-f];

Parameters

ParameterRequiredDescription
tableYesThe resource type. For more information about resource types, see Resource.
table_nameYesName of the MaxCompute table to register as a resource.
specRequired for partitioned tablesPartition to register. Only the specified partition is registered — not the entire table. Use the format partition_column='value', for example, ds='20150602'.
aliasNoResource name. Defaults to the file name if not specified. Not supported for JAR or Python script resources.
commentNoDescription of the resource.
-fNoOverwrites the existing resource if a resource with the same name already exists. Without this flag, adding a resource with a duplicate name fails.

Examples

Add a partitioned table as a resource

Register a single partition of sale_detail as a resource named sale.res, and force-overwrite if the resource already exists:

add table sale_detail partition (ds='20150602') as sale.res comment 'sale detail on 20150602' -f;

Expected output:

OK: Resource 'sale.res' have been updated.

What's next

After registering a table as a resource, reference it by name in MapReduce jobs or UDFs. To manage your resources, see the following statements:

Related ADD statements: