Skip to content
NEW BENCHMARKS

SurrealDB 3.x by the numbers

View

1/3

Course content preview

6: Deleting records

None of our place records have any useful information, so let's delete them to get ready to finally create the one library that we need. Two things to know when using DELETE are:

  • A DELETE statement followed by a table name will delete all of the records from that table.

  • When SurrealDB performs an operation, it returns the result after the operation. So for DELETE, it will return nothing (an empty array).

Here is a quick example that shows this behaviour.

CREATE some_record;
DELETE some_record;

Response

-------- Query 1 --------

[
{
id: some_record:wqewkk86z6qqi18yenhc
}
]

-------- Query 2 --------

[]

If you want to return the state before an operation, you can add RETURN BEFORE to the end of a query. This is especially useful in DELETE statements because it shows which records were deleted.

DELETE place RETURN BEFORE;

Response

[
{
id: place:b53ful62pogdxvjb57sh,
num_books: 10000,
place_type: 'library'
},
{
id: place:bx4iy7ckqzhyj5xkrba9
},
{
id: place:e6uldb0aoq4jib2kfgqs,
place_type: 'library'
},
{
id: place:⟨ma_bibliothèque⟩
},
{
id: place:mq62n1aic4nxpuiuss93
},
{
id: place:my_library
},
{
id: place:noamxxe7h1rx59403sdw
},
{
id: place:p2n354tklmfpgxl3bifs
},
{
id: place:⟨良い図書館⟩
},
{
id: place:⟨𒂍𒁾𒁀𒀀⟩
}
]

You can use a WHERE clause to delete records that match a certain condition, or DELETE on a single record ID to delete just one.

-- Delete everyone named "Bill":
-- might be zero, one, or more records
DELETE person WHERE name = "Bill";

-- Will only delete one record
DELETE person:bill;

You can also delete a range of records.

-- Delete from person:1 up to but not including person:3
DELETE person:1..3;

-- Delete from person:1 up to and including person:3
DELETE person:1..=3;
SurrealDB

The context layer for AI agents.

Documents, graphs, vectors, time-series, and memory - in one transaction, one query, one deployment.

Explore with AI

Independently verified

SOC 2 Type 2

GDPR

Cyber Essentials Plus

ISO 27001

Trust Centre

Copyright © 2026 SurrealDB Ltd. Registered in England and Wales. Company no. 13615201

Registered address: 3rd Floor 1 Ashley Road, Altrincham, Cheshire, WA14 2DT, United Kingdom

Trading address: Huckletree Oxford Circus, 213 Oxford Street, London, W1D 2LG, United Kingdom