LIST

statementsupportedData loading & unloading

docs.snowflake.com ↗

Returns a list of files from one of the following Snowflake storage features: - Stage Named internal - Named external - For a specified table - For the current user - Git repository clone in Snowflake LIST can be abbreviated to LS.

Syntax

supportedpartialnot supportednot scored

The syntax differs depending on whether you’re listing files in a stage or a Git repository clone.

LIST { internalStage | externalStage } [ PATTERN = '<regex_pattern>' ]

Where

internalStage ::=
    @[<namespace>.]<int_stage_name>[/<path>]
  | @[<namespace>.]%<table_name>[/<path>]
  | @~[/<path>]

Where

externalStage ::=
  @[<namespace>.]<ext_stage_name>[/<path>]

Where

LIST repositoryClone [ PATTERN = '<regex_pattern>' ]

Where

repositoryClone ::=
  @[<namespace>.]<repository_clone>/<path>

Parameters

NameRequiredDescription
internalStage | externalStagerequiredSpecifies 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.ExpandShow lessSee more Where: <namespace> is the database and/or schema in which the named stage or table resides. It is optional if a database and schema are currently in use within the session; otherwise, it is required. <path> is an optional case-sensitive path for files in the cloud storage location (i.e. files have names that begin with a common string) that limits access to a set of files. Paths are alternatively called prefixes or folders by different cloud storage services. 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"). Specifying a path provides a scope for the LIST command, potentially reducing the amount of time required to run the command.
repositoryClonerequiredSpecifies the name of the repository clone and the branch, tag, or commit for which to list files.@[namespace.]repository_clone/path When listing files from a Git repository clone, the path is required and must begin with one of the following: branches/branch_name List files from the specified branch. tags/tag_name List files from the specified tag. commits/commit_hash List files from the commit specified by the commit hash.ExpandShow lessSee more If the repository clone name or path includes spaces or special characters, it must be enclosed in single quotes (for example, '@"my repository"' for a repository named "my repository").
PATTERN = 'regex_pattern'optionalSpecifies a regular expression pattern for filtering files from the output. The command lists all files in the specified path and applies the regular expression pattern on each of the files found.

Usage notes

Output

The command returns columns in the following tables. Column values differ depending on whether you’re using LIST with a stage or Git repository clone. Column | Data type | Description name | VARCHAR | Name of the staged file size | NUMBER | Size of the file compressed (in bytes) md5 | VARCHAR | The MD5 column stores an MD5 hash of the contents of the staged data file. For internal stages with default encryption (SNOWFLAKE_FULL), during upload the source file is encrypted with a random key, and its resulting MD5 digest will always differ from the original local file. Amazon S3 stages report the value via the S3 eTag field, which might not be an MD5 hash of the file contents. For Google Cloud stages that use a customer-managed encryption key (CMEK), md5 is expected to be NULL. For more information, see Customer-managed encryption keys. sha1 | VARCHAR | Not used last_modified | VARCHAR | Timestamp when the file was last updated in the stage Column | Data type | Description name | VARCHAR | Full file path with extension size | NUMBER | Size of the file compressed (in bytes) md5 | VARCHAR | Not used sha1 | VARCHAR | A unique identifier generated by applying the SHA-1 hashing algorithm to the file’s contents. It is used by Git to track and reference the exact version of a file in the repository, and can be used to detect changes in the file’s content. last_modified | VARCHAR | Timestamp of the commit associated with the listed files. This does not necessarily indicate when the file content was last changed.

See also

Referenced by