Purpose
This statement is used to delete a file from an external storage location.
Limitations and considerations
Files of the 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
Parameters |
Description |
|---|---|
| location_name | The name of the target storage location, which is also the name of the Location object. |
| path | Optional. Indicates a subdirectory. |
| pattern_expr | Optional. Specifies the file matching pattern used to filter the 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 the file name or regular expression. ThePATTERNandREGEXP_PATTERNparameters are equivalent. Controls which files are loaded. Example:PATTERN = 'extdata.csv': Specifies the name of the file to load, which isextdata.csv.- 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. This allows for flexible matching of various file names. Example:REGEXP_PATTERN = '.*[.]csv$': Uses a regular expression to filter all files underLOCATIONthat end with.csv.
GLOB_PATTERN [=] 'glob_pattern': Specifies to use wildcards to match file names. This performs a simple match for common file types. Example:GLOB_PATTERN = '*.csv': Matches all files that end with.csv.
Examples
Delete the file under 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 file information under a location object, see SHOW.