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 permissions 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 a 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.

      You can save data files in the bin directory of the MaxCompute client. In this case, you must set path to a value in the File name.File name extension format. You can also save data files to another directory, such as the test folder in drive D. In this case, you must set path to a value in the D:\test\File name.File name extension format.

    • 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 a 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. The log.txt file is saved in the bin folder of the MaxCompute client. Sample statements:
      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. The log.txt file is saved in the test folder on drive D. Sample statements:
      Tunnel upload D:\test\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 a 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 a 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.

      You can save data files in the bin directory of the MaxCompute client. In this case, you must set path to a value in the File name.File name extension format. You can also save data files to another directory, such as the test folder in drive D. In this case, you must set path to a value in the D:\test\File name.File name extension format.

  • Examples
    • Example 1: Download data from the second-level partitioned table test_project.test_table to the test_table.txt file. The test_table.txt file is saved in the bin folder of the MaxCompute client. Sample statements:
      Tunnel download test_project.test_table/p1="b1",p2="b2" test_table.txt;
    • Example 2: Download data from the second-level partitioned table test_project.test_table to the test_table.txt file. The test_table.txt file is saved in the test folder on drive D. Sample statements:
      Tunnel download test_project.test_table/p1="b1",p2="b2" D:\test\test_table.txt;