Purpose
This statement is used to delete files from an external storage location.
Note
For OceanBase Database V4.4.x, the REMOVE statement is supported starting from V4.4.1.
Limitations and considerations
Files in a local location object cannot be deleted.
Privilege requirements
To execute the REMOVE statement, the current user must have the WRITE privilege on the location object. For more information about granting privileges on location objects to users, see GRANT.
Syntax
REMOVE FILES IN LOCATION @location_name['/path'] [pattern_expr];
pattern_expr:
PATTERN [=] 'regex_pattern'
| REGEXP_PATTERN [=] 'regex_pattern'
| GLOB_PATTERN [=] 'glob_pattern'
Parameters
Parameter |
Description |
|---|---|
| location_name | The name of the target storage location, which is the name of the location object. |
| path | Optional. The name of a subdirectory. |
| pattern_expr | Optional. A file matching pattern used to filter files to be deleted in the LOCATION directory. If this parameter is not specified, all files in the LOCATION directory are deleted by default. |
pattern_expr
PATTERN [=] 'regex_pattern': Specifies a file name or a regular expression. ThePATTERNandREGEXP_PATTERNparameters are equivalent. Controls which files are loaded. Examples:PATTERN = 'extdata.csv': Specifies that the fileextdata.csvis to be loaded.- For multiple CSV files, such as
extdata_2024.csvandextdata_2025.csv, you can writePATTERN = 'extdata_\d{4}\.csv'.
REGEXP_PATTERN [=] 'regex_pattern': Specifies to use a regular expression to match file names. Matches various file names flexibly. Example:REGEXP_PATTERN = '.*[.]csv$': Uses a regular expression to filter all files ending with.csvunderLOCATION.Note
For V5.x versions, the
REGEXP_PATTERNparameter is available starting from V5.0.1.
GLOB_PATTERN [=] 'glob_pattern': Specifies to use wildcard characters to match file names. Matches common file types simply. Example:GLOB_PATTERN = '*.csv': Matches all files ending with.csv.Note
For V5.x versions, the
GLOB_PATTERNparameter is available starting from V5.0.1.
Examples
Delete files in the test_location_oss location object.
obclient> REMOVE FILES IN LOCATION @test_location_oss;
References
- For more information about creating a location object, see CREATE LOCATION.
- For more information about viewing files in a location object, see SHOW.
