SurrealDB has a variety of statements that let you configure and query a database. In this section, we’ll look at the different types of statements that are available.
SurrealDB has a large variety of statements. They can be divided into three types:
These statements pertain to defining, removing, altering, and rebuilding database resources. They are:
DEFINE statements to define database resources,ALTER statements to alter certain resources (note: DEFINE statements with the OVERWRITE clause are more frequently used),REMOVE statements to remove resources,REBUILD to rebuild an index,ACCESS to manage access grants.Some other statements pertain to using defined resources. They are:
USE to move from one namespace or database to another,INFO statements to see the definitions for resources,SHOW to see the changefeed for a table or database.These statements are used to describe how query execution should progress.
Some control flow statements only pertain to manual transactions. While all statements in SurrealDB are conducted inside their own transaction, these statements can be used to manually set up a larger transaction composed of multiple statements. They are:
Other control flow statements are used in the same manner as in other programming languages. They are:
FOR to begin a for loop,CONTINUE to continue to the next iteration of a loop,BREAK to break out of a for loop, internal scope, function, etc.,IF and ELSE to describe what to do depending on a condition,SLEEP to halt all execution for a certain length of time,RETURN to break and return a value,THROW to cancel execution and return an error.These statements are used to execute queries, most often but not always in the context of a CRUD operation.
The statements that pertain to the handling of records are:
CREATE to create one or more records of one or more types of tables,INSERT to create one or more regular records or graph edges,RELATE to create a single graph edge between two records,UPDATE to update records,UPSERT to update a record and create a new one if it does not exist,SELECT to select records (but also ad-hoc values),LIVE SELECT to stream all the changes to a table,DELETE to delete one or more records,KILL to cancel a LIVE SELECT.The other statements used when executing a query are:
LET to assign a value to a parameter for later use,RETURN when used in front of a value or expression, in which case it has no effect but is often used for readability.The following flowchart can be used to get a sense of when it makes sense to use CREATE, INSERT, UPDATE, UPSERT, and RELATE.

A number of parameters prefixed with $ are automatically available within a statement that provide access to relevant context inside the statement. These are known as reserved variable names. For example:
For a full list of these automatically generated parameters, see the parameters page.