REMOVE | Snowflake Documentation (original) (raw)

Removes files from either an external (external cloud storage) or internal (i.e. Snowflake) stage.

For internal stages, the following stage types are supported:

REMOVE can be abbreviated to RM.

See also:

LIST

Syntax

REMOVE { internalStage | externalStage } [ PATTERN = '' ]

Where:

internalStage ::= @[.][/] | @[.]%[/] | @~[/]

externalStage ::= @[.][/]

Required parameters

internalStage | externalStage

Specifies the location where the data files are staged:

@[namespace.]_int_stage_name_[/_path_] Files are in the specified named internal stage.
@[namespace.]_ext_stage_name_[/_path_] Files are in the specified named external stage.
@[namespace.]%_table_name_[/_path_] Files are in the stage for the specified table.
@~[/_path_] Files are in the stage for the current user.

Where:

Note

If the stage name or path includes spaces or special characters, it must be enclosed in single quotes (e.g. '@"my stage"'for a stage named "my stage").

Optional parameters

PATTERN = '_regexpattern_'

Specifies a regular expression pattern for filtering files to remove. The command lists all files in the specified _path_and applies the regular expression pattern on each of the files found.

Usage notes

Examples

Remove all files from the path1/subpath2 path in a named internal or external stage named mystage:

REMOVE @mystage/path1/subpath2;

Remove all files from the stage for the orders table:

Use the abbreviated form of the command to remove files whose names match the pattern *jun* from the stage for the current user: