MaxCompute allows you to run Tunnel commands to upload and download data. This topic describes how to upload and download data by using Tunnel commands.

For more information about Tunnel operations, see Tunnel commands. The following table describes common commands that are used for Tunnel operations.
Operation Description Role Operation platform
Upload data Uploads local data to a MaxCompute table in append mode. Users who have the ALTER permission on tables You must run the commands described in this topic on the MaxCompute client.
Download data Downloads MaxCompute table data or the execution results of a specified instance to a directory on your on-premises machine. Users who have the SELECT permission to read table data

Upload data

Uploads local data to a MaxCompute table in append mode. You are not charged when you upload data to MaxCompute.

  • Limits
    • You can upload files or level-1 directories to only one table or one partition in a table each time.
    • For a partitioned table, you must specify the partition to which you want to upload data. If the table has multiple levels of partitions, you must specify the lowest-level partition.
  • Syntax
    Tunnel upload <path> [<project_name>.]<table_name>[/<pt_spc>];
  • Parameters
    • path: required. The directory and name of the data file that you want to upload from your on-premises machine. The default format of data files is TXT.
    • project_name: optional. The name of the project to which the destination table belongs. This parameter is required when you access tables across projects.
    • table_name: required. The name of the destination table.
    • pt_spc: optional. The partitions that are specified in a partitioned table. You must specify the lowest-level partition. The value of this parameter is in the partition_col1=col1_value1, partition_col2=col2_value1... format.
  • Examples
    • Example 1: Upload data in the log.txt file to the test_table table of the current project.
      Tunnel upload log.txt test_table;
    • Example 2: Upload data in the log.txt file to the p1="b1",p2="b2" partitions of the test_table table in the test_project project. The table has two levels of partitions.
      Tunnel upload log.txt test_project.test_table/p1="b1",p2="b2";

Download data

Downloads MaxCompute table data or the execution results of a specified instance to a directory on your on-premises machine. You can download MaxCompute data only from the Internet. You are charged based on the size of data that is downloaded. The fee is calculated by using the following formula: Fee per download = Amount of data downloaded (GB) × Unit price of download (USD 0.1166/GB).

  • Limits
    • You can download data from only one table or one partition to a single local file each time.
    • For a partitioned table, you must specify the partition from which you want to download data. If the table has multiple levels of partitions, you must specify the lowest-level partition.
  • Syntax
    Tunnel download [<project_name>.]<table_name>[/<pt_spc>] <path>;
  • Parameters
    • project_name: optional. The name of the project to which the destination table belongs. This parameter is required when you access tables across projects.
    • table_name: required. The name of the destination table.
    • pt_spc: optional. The partitions that are specified in a partitioned table. You must specify the lowest-level partition. The value of this parameter is in the partition_col1=col1_value1, partition_col2=col2_value1... format.
    • path: required. The directory and name of the downloaded data file. The default format of the downloaded data file is TXT.
  • Example
    -- Download data from the test_project.test_table table to the test_table.txt file. The table has two levels of partitions.
    Tunnel download test_project.test_table/p1="b1",p2="b2" test_table.txt;