CREATE SCHEDULE lets you run SQL automatically in Amazon Redshift on a cron-based timetable.
Automates recurring SQL so you never log in to rerun analytics, roll-ups, or maintenance tasks.
Run the following SQL as a superuser or a user with sys:orchestration privileges.
CREATE SCHEDULE daily_midnight
CRON ('0 0 * * ? *')
ENABLE; -- ready to run
Wrap your SQL in CREATE SCHEDULED QUERY and reference daily_midnight
.
CREATE SCHEDULED QUERY daily_revenue_refresh
SCHEDULE daily_midnight
RUN AS ROLE 'arn:aws:iam::123456789012:role/redshift-query-runner'
AS
INSERT INTO daily_revenue(date, revenue)
SELECT order_date, SUM(total_amount)
FROM Orders
GROUP BY order_date;
Disable it temporarily or drop it permanently.
ALTER SCHEDULE daily_midnight DISABLE;
DROP SCHEDULE daily_midnight;
Query SVV_SCHEDULED_QUERIES
for status and SVL_SCHEDULED_QUERY_EXECUTION
for run history and failure reasons.
Keep SQL idempotent, add logging tables, specify RUN AS ROLE
explicitly, and use ALLOW_CONCURRENT_EXECUTION
only when duplicate runs are safe.
Redshift schedules interpret CRON strings in UTC. Convert your desired local time to UTC before creating the schedule.
It runs with the IAM role you pass in RUN AS ROLE. Grant that role the exact database privileges the query needs—no more, no less.
Issue ALTER SCHEDULE with a new CRON string: ALTER SCHEDULE daily_midnight CRON ('0 6 * * ? *');
The change takes effect immediately.