Skip to content
NEW

Introducing SurrealDB Studio, the new official app of SurrealDB

Learn more

1/5

Course content preview

2: Creating records

To create a library, we are going to need a record for it. A CREATE statement followed by a table name is all that we need to create a record.

CREATE library;


But since our town is going to have all sorts of places, let's choose a more general table name: place. We can use the SET keyword to give this record a field called place_type so that we know a bit more about it.

CREATE place SET place_type = "library";


Response
[
  {
    id: place:dg96emq8s3rkaxpdrfq9,
    place_type: 'library'
  }
]


Since we didn't give this place record an ID, SurrealDB will create a random one. Record IDs are composed of the table name, a : after the table name, and something else. If you don't choose an exact record ID, a random GUID (a Globally Unique Identifier) will be added after the : which gives an output like place:wrwfldojvfcyl9gbe5v3.

But you can choose your own record ID instead, like place:1 or place:my_library. Just make sure it hasn't already been used, because you can't create two records with the same ID.

-- Works fine 
CREATE place:my_library;
-- Error: already exists
CREATE place:my_library;


Response
-------- Query --------

[
  {
    id: place:my_library
  }
]

-------- Query --------

'Database record `place:my_library`
already exists'


Previous

1: Connecting to a database

Next lesson

3: Using the ONLY keyword

SurrealDB

The unified data layer for AI

Graph, vector, document, and relational in one engine.
Agent Memory that connects and retrieves context wherever your data lives.

Explore with AI

Stay in the loop

Tutorials, AI agent recipes, and product updates, every two weeks.

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