CREATE DATA MOVEMENT RULE

statementsupportedGovernance (policies, tags, data quality)Enterprise+

docs.snowflake.com ↗

Object: DATA MOVEMENT RULE

Creates a new data movement rule in the current/specified schema or replaces an existing data movement rule. A data movement rule controls a single movement type and returns the maximum number of rows that the movement type can move. After you create a data movement rule, add it to a data movement policy so that Snowflake enforces or reports on it.

Syntax

supportedpartialnot supportednot scored

CREATE [ OR REPLACE ] DATA MOVEMENT RULE [ IF NOT EXISTS ] <name>
  TYPE = '<movement_type>'
  MAX_ROWS AS () RETURNS INTEGER
  -> ( <expression> )
  [ COMMENT = '<string_literal>' ]

Parameters

NameRequiredDescription
namerequiredString that specifies the identifier (that is, name) for the data movement rule; must be unique for the schema in which the data movement rule is created. In addition, the identifier must start with an alphabetic character and cannot contain spaces or special characters unless the entire identifier string is enclosed in double quotes (for example, "My object"). Identifiers enclosed in double quotes are also case-sensitive. For more information, see Identifier requirements.
TYPE = 'movement_type'requiredSpecifies the movement type that the rule controls. A rule controls exactly one movement type. Supported values: COPY_INTO_EXTERNAL_STAGE - Rows unloaded to an external stage with COPY INTO <location>. COPY_INTO_INTERNAL_STAGE - Rows unloaded to an internal stage with COPY INTO <location>. SNOWSIGHT_UI - Rows returned to the Snowsight worksheet results grid. AGENT_ACCESS - Rows accessed by an agent. UI_DOWNLOAD - Rows downloaded via the Download button in Snowsight (workspace results pane, notebook cells, Query History, and query results in Snowflake CoWork). Does not apply to all download surfaces; for example, downloads in Streamlit apps, notebooks in the Visual Studio Code extension, and the Export as HTML option in workspaces are not covered. PROGRAMMATIC_FETCH - Rows fetched programmatically, for example through a driver or connector.
MAX_ROWS AS () RETURNS INTEGER -> ( expression )requiredSQL expression body that returns an INTEGER, which sets the maximum number of rows that the movement type can move. The return value determines the behavior: NULL - No limit on the number of rows. 0 - Block the movement. A positive integer - The maximum number of rows that the movement type can move. The expression can contain CASE and other logic statements. It can call SYS_CONTEXT to read session and movement context and adjust the returned limit accordingly.
COMMENT = 'string_literal'optionalSpecifies a comment for the data movement rule. Default: No value

Usage notes

Access control requirements

A role used to execute this operation must have the following privileges at a minimum: Privilege | Object | Notes CREATE DATA MOVEMENT RULE | Schema | Operating on an object in a schema requires at least one privilege on the parent database and at least one privilege on the parent schema. For instructions on creating a custom role with a specified set of privileges, see Creating custom roles. For general information about roles and privilege grants for performing SQL actions on securable objects, see Overview of Access Control.

See also

Referenced by