Light
Dark
System
v4latest
v5dev
v4latest
v3
v2
v1

Delete

delete – remove objects from a database.

[ with with-item [, ...] ]

delete expr

[ filter filter-expr ]

[ order by order-expr [direction] [then ...] ]

[ offset offset-expr ]

[ limit  limit-expr ] ;
with

Alias declarations.

The with clause allows specifying module aliases as well as expression aliases that can be referenced by the delete statement. See With block for more information.

delete ...

The entire delete ... statement is syntactic sugar for delete (select ...). Therefore, the base expr and the following filter, order by, offset, and limit clauses shape the set to be deleted the same way an explicit select would.

On successful completion, a delete statement returns the set of deleted objects.

Here’s a simple example of deleting a specific user:

Copy
with module example
delete User
filter User.name = 'Alice Smith';

And here’s the equivalent delete (select ...) statement:

Copy
with module example
delete (select User
        filter User.name = 'Alice Smith');
Light
Dark
System

We use ChatGPT with additional context from our documentation to answer your questions. Not all answers will be accurate. Please join our Discord if you need more help.