SurrealDB Docs Logo

Enter a search query

KILL statement

The KILL statement is used to terminate a running live query.

While the KILL statement does accept a value type, this value must resolve to a UUID. Consequently, it will accept a string literal of a UUID or a param.

Statement syntax

SurrealQL Syntax
KILL @value;

Example usage

Basic usage

The KILL statement expects the UUID of a running live select query to be passed. This UUID can be found in the output of the LIVE statement, and can thereafter be passed into a KILL statement once it is no longer needed.

LIVE SELECT DIFF FROM person;
-- output: u'0189d6e3-8eac-703a-9a48-d9faa78b44b9'

-- Some time later...
KILL u"0189d6e3-8eac-703a-9a48-d9faa78b44b9";

The KILL statement also allows for parameters to be used.

-- Define the parameter
LET $live_query_id = u"0189d6e3-8eac-703a-9a48-d9faa78b44b9";
-- Use the parameter
KILL $live_query_id;

Using the KILL statement on a UUID that does not correspond to a running live query will generate an error.

LET $rand = rand::uuid();
KILL $rand;
KILL u'9276b05b-e59a-49cd-9dd1-17c6fd15c28f';
Output
"Can not execute KILL statement using id '$rand'" "Can not execute KILL statement using id 'u'9276b05b-e59a-49cd-9dd1-17c6fd15c28f''"

On this page

© SurrealDB GitHub Discord Community Cloud Features Releases Install