Modify Table Partition Location
Function
Modify the storage location of an OBS table partition. This command only supports OBS tables (external tables) and does not support managed tables.
Syntax
ALTER TABLE table_name PARTITION partition_specs SET LOCATION 'obs_path';
Keywords
- PARTITION: Specify the partition whose location is to be modified.
- SET LOCATION: Set the new storage path for the partition.
- LOCATION: Partition path, must be in OBS format.
Parameters
| Parameter | Mandatory | Description |
|---|---|---|
| table_name | Yes | Table name. |
| partition_specs | Yes | Partition specification, in the format (col1=val1, col2=val2, ...). The partition must already exist. |
| obs_path | Yes | New OBS storage path, which must be an existing absolute path. |
Precautions
- This command only supports OBS tables (external tables) and does not support managed tables.
- The table partition whose location is to be modified must already exist. Otherwise, an error will be reported.
- The specified new OBS path must be an existing absolute path. Otherwise, an error will be reported.
- If the new path contains subdirectories, all file types and contents under the subdirectories will also be considered records of that partition. Ensure consistency with the table fields.
- Modifying the partition location does not automatically migrate existing data.
Example 1: Modify the Partition Location for a Single Partition Column
ALTER TABLE student PARTITION (dt='2008-08-08') SET LOCATION 'obs://my-bucket/student/dt=2008-08-08/';
Example 2: Modify the Partition Location for Multiple Partition Columns
ALTER TABLE student PARTITION (dt='2008-08-08', city='beijing') SET LOCATION 'obs://my-bucket/student/dt=2008-08-08/city=beijing/';
Example 3: Verify Partition Location After Modification
ALTER TABLE student PARTITION (dt='2008-08-08') SET LOCATION 'obs://my-bucket/student/new_path/'; SHOW PARTITIONS student;
Example 4: Modify the Partition Location for a Table in a Specified Database
ALTER TABLE myschool.student PARTITION (class='101') SET LOCATION 'obs://my-bucket/myschool/student/class=101/';
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot