SHOW TASKS | Snowflake Documentation

Lists the tasks for which you have access privileges. The command can be used to list tasks for the current/specified database or schema, or across your entire account.

The output returns task metadata and properties, ordered lexicographically by database, schema, and task name (see Output in this topic for descriptions of the output columns). This is important to note if you wish to filter the results using the provided filters.

See also:

CREATE TASK , ALTER TASK , DROP TASK , DESCRIBE TASK

Syntax

SHOW [ TERSE ] TASKS [ LIKE '<pattern>' ]
                     [ IN { ACCOUNT | DATABASE [ <db_name> ] | [ SCHEMA ] [ <schema_name> ] | APPLICATION <application_name> | APPLICATION PACKAGE <application_package_name> } ]
                     [ STARTS WITH '<name_string>' ]
                     [ ROOT ONLY ]
                     [ LIMIT <rows> [ FROM '<name_string>' ] ]

Parameters

TERSE

Returns only a subset of the output columns:

  • created_on

  • name

  • kind (shows NULL for all task records)

  • database_name

  • schema_name

  • schedule

LIKE 'pattern'

Optionally filters the command output by object name. The filter uses case-insensitive pattern matching, with support for SQL wildcard characters (% and _).

For example, the following patterns return the same results:

... LIKE '%testing%' ...

... LIKE '%TESTING%' ...

. Default: No value (no filtering is applied to the output).

IN ACCOUNT | DATABASE [ db_name ] | SCHEMA [ schema_name ] | APPLICATION application_name | APPLICATION PACKAGE application_package_name

Optionally specifies the scope of the command, which determines whether the command lists records only for the current/specified database or schema, or across your entire account.

The APPLICATION and APPLICATION PACKAGE keywords are not required, but they specify the scope for the named Snowflake Native App.

If you specify the keyword ACCOUNT, then the command retrieves records for all schemas in all databases of the current account.

If you specify the keyword DATABASE, then:

  • If you specify a db_name, then the command retrieves records for all schemas of the specified database.

  • If you don’t specify a db_name, then:

    • If there is a current database, then the command retrieves records for all schemas in the current database.

    • If there is no current database, then the command retrieves records for all databases and schemas in the account.

If you specify the keyword SCHEMA, then:

  • If you specify a qualified schema name (for example, my_database.my_schema), then the command retrieves records for the specified database and schema.

  • If you specify an unqualified schema_name, then:

    • If there is a current database, then the command retrieves records for the specified schema in the current database.

    • If there is no current database, then the command displays the error SQL compilation error: Object does not exist, or operation cannot be performed.

  • If you don’t specify a schema_name, then:

    • If there is a current database, then:

      • If there is a current schema, then the command retrieves records for the current schema in the current database.

      • If there is no current schema, then the command retrieves records for all schemas in the current database.

    • If there is no current database, then the command retrieves records for all databases and all schemas in the account.

Default: Depends on whether the session currently has a database in use:

  • Database: DATABASE is the default; that is, the command returns the objects that you have privileges to view in the database.

  • No database: ACCOUNT is the default; that is, the command returns the objects that you have privileges to view in your account.

STARTS WITH 'name_string'

Optionally filters the command output based on the characters that appear at the beginning of the object name. The string must be enclosed in single quotes and is case sensitive.

For example, the following strings return different results:

... STARTS WITH 'B' ...

... STARTS WITH 'b' ...

. Default: No value (no filtering is applied to the output)

ROOT ONLY

Filters the command output to return only root tasks (tasks with no predecessors).

LIMIT rows [ FROM 'name_string' ]

Optionally limits the maximum number of rows returned, while also enabling “pagination” of the results. The actual number of rows returned might be less than the specified limit. For example, the number of existing objects is less than the specified limit.

The optional FROM 'name_string' subclause effectively serves as a “cursor” for the results. This enables fetching the specified number of rows following the first row whose object name matches the specified string:

  • The string must be enclosed in single quotes and is case sensitive.

  • The string does not have to include the full object name; partial names are supported.

Default: No value (no limit is applied to the output)

Note

For SHOW commands that support both the FROM 'name_string' and STARTS WITH 'name_string' clauses, you can combine both of these clauses in the same statement. However, both conditions must be met or they cancel out each other and no results are returned.

In addition, objects are returned in lexicographic order by name, so FROM 'name_string' only returns rows with a higher lexicographic value than the rows returned by STARTS WITH 'name_string'.

For example:

  • ... STARTS WITH 'A' LIMIT ... FROM 'B' would return no results.

  • ... STARTS WITH 'B' LIMIT ... FROM 'A' would return no results.

  • ... STARTS WITH 'A' LIMIT ... FROM 'AB' would return results (if any rows match the input strings).

Output

The command output provides task properties and metadata in the following columns:

For more information about the properties that can be specified for a task, see CREATE TASK.

Usage notes

  • Only returns rows for a task owner—that is, the role with the OWNERSHIP privilege on a task—or a role with either the MONITOR or OPERATE privilege on a task.

  • The command doesn’t require a running warehouse to execute.

  • The command only returns objects for which the current user’s current role has been granted at least one access privilege.

  • The MANAGE GRANTS access privilege implicitly allows its holder to see every object in the account. By default, only the account administrator (users with the ACCOUNTADMIN role) and security administrator (users with the SECURITYADMIN role) have the MANAGE GRANTS privilege.

  • To post-process the output of this command, you can use the pipe operator (->>) or the RESULT_SCAN function. Both constructs treat the output as a result set that you can query.

    For example, you can use the pipe operator or RESULT_SCAN function to select specific columns from the SHOW command output or filter the rows.

    When you refer to the output columns, use double-quoted identifiers for the column names. For example, to select the output column type, specify SELECT "type".

    You must use double-quoted identifiers because the output column names for SHOW commands are in lowercase. The double quotes ensure that the column names in the SELECT list or WHERE clause match the column names in the SHOW command output that was scanned.

  • The value for LIMIT rows can’t exceed 10000. If LIMIT rows is omitted, the command results in an error if the result set is larger than ten thousand rows.

    To view results for which more than ten thousand records exist, either include LIMIT rows or query the corresponding view in the Snowflake Information Schema.

Examples

Show all the tasks whose name starts with line that you have privileges to view in the tpch.public schema:

SHOW TASKS LIKE 'line%' IN tpch.public;

Show all the tasks that you have privileges to view in the tpch.public schema:

SHOW TASKS IN tpch.public;