Skip to content
NEW BENCHMARKS

SurrealDB 3.x by the numbers

View

1/3

Course content preview

11: Updating records

A library all on its own isn't all that interesting, so let's create the town that holds it.

CREATE town:riverdale SET name = "Riverdale";

Response

[
{
id: town:riverdale,
name: 'Riverdale'
}
]

If we want, we can select both the library and town inside a single statement.

SELECT * FROM place, town;

Response

[
{
address: '2025 Statement Street, Riverdale',
floors: 8,
id: place:surreal_library,
name: 'Surreal Library',
place_type: 'library'
},
{
id: town:riverdale,
name: 'Riverdale'
}
]

However, while these two records have turned up in the same query, they aren't actually connected to each other. It would be nice to link the two so that we could always access the library inside queries on the town. To do this, we can update the town record to add a link to the library.

UPDATE is similar to CREATE in that it can be followed by SET to set values for the fields. And like a SELECT statement, an UPDATE for a table without a WHERE will update every record for the table. A WHERE clause isn't truly needed here because we only have one town, but let's add it to make it clear. Also, this will guarantee that only the town of "Riverdale" gets updated even if we add more town records later.

To practice, we will first update Riverdale to give it a population of 75000.

UPDATE town
SET population = 75000
WHERE name = "Riverdale";

Response

[
{
id: town:riverdale,
name: 'Riverdale',
population: 75000
}
]

Now that we know how to update records, we can update this town again in the next page with a link.

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