Statements
SurrealDB has a large number of different SurrealQL statements for inserting, updating, deleting, working with graph data, and for configuring the database. View detailed information and examples on how to use each statement type below.
USE
statement
Used to switch to a different namespace or database
LET
statement
Used to set and store values which can be used in queries
BEGIN
statement
Used to mark the beginning of a group of statements in a transaction
CANCEL
statement
Used to cancel the execution of a group of statements within a transaction
COMMIT
statement
Used to apply a group of statements within a transaction to the database
IF ELSE
statement
Used to conditionally perform operations on the database
FOR
statement
Used to loop over arrays or other forms of iterators
BREAK
statement
Used to break out of a loop
CONTINUE
statement
Used to skip an iteration in a loop
SELECT
statement
Used for selecting and querying data in a database
LIVE SELECT
statement
Used to initiate a custom live query against a table
KILL
statement
Used to terminate a running live query
INSERT
statement
Used to insert or update data into the database
CREATE
statement
Used to add records to the database
UPDATE
statement
Used to update or modify records in the database
RELATE
statement
Used to generate graph edges between two records in the database
RETURN
statement
Used to return a value or result of query, and to set the result of a transaction or block.
DELETE
statement
Used to delete records from the database
DEFINE
statement
Used to declare database rules, schemas, events and more
REMOVE
statement
Used to remove resources such as databases, tables, indexes, events and more
INFO
statement
Outputs information for a specified resource
SHOW
statement
Replay changes made to the table
SLEEP
statement
Delays or pauses in the execution of a query or a batch
THROW
statement
Used to throw custom errors