CREATE MAINTENANCE POLICY

Creates a new maintenance policy in the current or specified schema.

See also:

ALTER MAINTENANCE POLICY, DROP MAINTENANCE POLICY, SHOW MAINTENANCE POLICIES

Syntax

CREATE [ OR REPLACE ] MAINTENANCE POLICY [ IF NOT EXISTS ] <name>
  SCHEDULE = 'USING CRON <cron_spec> <timezone>'
  [ COMMENT = '<comment>' ]

Required parameters

name

Specifies the identifier of the maintenance policy. The identifier must be unique within the schema.

SCHEDULE = 'USING CRON cron_spec timezone

Specifies the schedule for the maintenance policy. This parameter uses the same syntax as the SCHEDULE parameter of the CREATE TASK command.

Optional parameters

COMMENT = 'comment'

Specifies an optional comment for the maintenance policy.

Access control requirements

A role used to execute this operation must have the following privileges at a minimum:

PrivilegeObjectNotes
CREATE MAINTENANCE POLICYSchema

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.

Usage notes

  • Each app or account can have only one maintenance policy.

  • Regarding metadata:

    Attention

    Customers should ensure that no personal data (other than for a User object), sensitive data, export-controlled data, or other regulated data is entered as metadata when using the Snowflake service. For more information, see Metadata fields in Snowflake.

Examples

The following example creates a maintenance policy that schedules upgrades for Saturdays at 2 AM UTC:

CREATE MAINTENANCE POLICY my_maintenance_policy
  SCHEDULE = 'USING CRON 0 2 * * SAT UTC'
  COMMENT = 'Weekly Saturday maintenance window';