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 a location object to a user, 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. This parameter controls which files are loaded. Examples:PATTERN = 'extdata.csv': Specifies that the fileextdata.csvshould be loaded.- If there are 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. This allows flexible matching of various file names. Example:REGEXP_PATTERN = '.*[.]csv$': Uses a regular expression to filter out all files with the.csvextension underLOCATION.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. This allows simple matching of common file types. Example:GLOB_PATTERN = '*.csv': Matches all files with the.csvextension.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.
