CANCEL JOB statement lets you stop long-running jobs, which include:
IMPORTjobsBACKUPandRESTOREjobs- User-created table statistics jobs
- Automatic table statistics jobs
- Changefeeds
- Scheduled backup jobs
- Schema change jobs (see Known limitations for exceptions)
Known limitations
- To avoid transaction states that cannot properly roll back, the following statements cannot be cancelled with
CANCEL JOB:DROPstatements (e.g.,DROP TABLE).ALTER... RENAMEstatements (e.g.,ALTER TABLE... RENAME TO).CREATE TABLE... ASstatements.ALTER TYPEstatements, except for those that drop values.
- When an Enterprise
RESTOREis canceled, partially restored data is properly cleaned up. This can have a minor, temporary impact on cluster performance.
Required privileges
To cancel a job, the user must be a member of theadmin role or must have the CONTROLJOB role option set. Non-admin users cannot cancel admin users’ jobs.
For changefeeds, users with the CHANGEFEED privilege on a set of tables can cancel changefeed jobs running on those tables.
Synopsis
Cancel all jobs by type
Parameters
Examples
Cancel a single job
Cancel multiple jobs
To cancel multiple jobs, nest aSELECT clause that retrieves job_id(s) inside the CANCEL JOBS statement:
maxroach will be cancelled.
Cancel by job type
To cancel all jobs by the type of job, use theCANCEL ALL {job} JOBS statement. You can cancel all BACKUP, RESTORE, CHANGEFEED, IMPORT jobs using this statement, for example:
Cancel automatic table statistics jobs
Canceling an automatic table statistics job is not useful since the system will automatically restart the job immediately. To permanently disable automatic table statistics jobs, disable thesql.stats.automatic_collection.enabled cluster setting:
Cancel jobs for a schedule
To cancel jobs for a specific backup schedule, use the schedule’sid:
SELECT clause that retrieves id(s) inside the CANCEL JOBS statement:

