Chalk SQL
Create a suspended Chalk SQL job with a recurring schedule and an optional resource group.
CREATE JOB creates a SQL job in the SUSPENDED state. Use OR REPLACE to update
an existing SQL job. Use
ALTER JOB ... RESUME to start scheduled runs.
{ CREATE JOB [ IF NOT EXISTS ] | CREATE OR REPLACE JOB } <name>
{ SCHEDULE = '<schedule>' [ RESOURCE_GROUP = '<resource_group>' ]
| RESOURCE_GROUP = '<resource_group>' SCHEDULE = '<schedule>' }
AS <statement>;
| Parameter | Description |
|---|---|
<name> | A SQL identifier unique among the environment’s SQL jobs and the scheduled jobs in its active deployment. |
<schedule> | A Chalk duration such as 1m or a five-field UTC cron expression such as 0 9 * * *. |
<statement> | One Chalk SQL statement to run each time the job fires. |
| Parameter | Description |
|---|---|
IF NOT EXISTS | Returns the existing SQL job with the same name. If the name is available, creates a suspended job. |
OR REPLACE | Lets the job creator update the statement, schedule, and resource group while preserving run history and the active or suspended state. If the name is available, creates a suspended job. Each run reads the job statement when it submits the query. |
RESOURCE_GROUP | The resource group for async SQL execution. If omitted, the job uses the environment’s default group. |
The command returns one row describing the resulting schedule with the columns of chalk.jobs.
Creating or replacing a SQL job requires query.online, cron.create, and workflow.manage
in the environment. Returning an existing SQL job with IF NOT EXISTS also requires workflow.read.
Create a job scheduled for 09:00 UTC every day.
CREATE JOB morning_report
SCHEDULE = '0 9 * * *'
AS SELECT 42 AS answer;
Update the job to run at 10:00 UTC every day.
CREATE OR REPLACE JOB morning_report
SCHEDULE = '0 10 * * *'
AS SELECT 42 AS answer;