Skip to content

Schemafull CRUD

Now that we've learned how to define both tables and fields, It's time for some schemafull CRUD.

In this lesson, we'll only cover what is different from schemaless CRUD, namely how to update the schema and data for tables and fields using:

  • The FIELD clause on the REMOVE statement

  • The OVERWRITE clause on the DEFINE statement

  • The ALTER statement

When updating our schemaless tables, we could just SET or UNSET fields and they would appear. Not so for a SCHEMAFULL table, however.

UPDATE product:01FSXKCPVR8G1TVYFT4JFJS5WB
SET new_field = "why not?";

UPDATE product UNSET category;


In both of these cases we get a schema error. In the first case it's because the new_field field hasn't been defined yet, and in the second because category is a field that can't hold the value NONE, which is what UNSET is trying to do.

For our second UPDATE query which tries to UNSET the category field on our product table, we also get a schema error.

REMOVE FIELD category ON TABLE product;

SELECT category FROM product limit 1;

UPDATE product;

SELECT * FROM product limit 1;


In order to remove a field from our schemafull table, we first need to use the REMOVE FIELD statement.

However, that is not enough to actually remove the field data, as the REMOVE FIELD statement only removes the schema definition.

Once the schema definition is removed, we can use UNSET like we did earlier.

There is however another way, if removing multiple fields, we can simply run UPDATE product and the UPDATE statement will remove anything that is no longer a part of the schema definition.

For updating existing schema definitions there are two options:

  • The OVERWRITE clause on the DEFINE statement

  • The ALTER statement.

For example, we can change the datatype of a field or change a table from schemafull to schemaless.

-- Change from a generic number type to float
DEFINE FIELD OVERWRITE price ON TABLE product TYPE float;

-- Change from schemafull to schemaless
DEFINE TABLE OVERWRITE product TYPE NORMAL SCHEMALESS;

-- Change again from schemaless to schemafull
ALTER TABLE product SCHEMAFULL;


The difference between these two options is that

  • DEFINE ... OVERWRITE can be used to both create new definitions and update existing ones, but needs to include the entire definition.

  • The ALTER statement only updates existing definitions and only needs to include the items to be updated, not the entire definition.

Let's summarise what we've learned.

When adding and removing fields:

  • You need to use DEFINE FIELD to add the field to the schema before using UPDATE to add the data.

  • You need to use REMOVE FIELD to remove the field from the schema before using UPDATE to remove the data.

When updating fields and tables:

  • DEFINE ... OVERWRITE can be used to both create new definitions and update existing ones, but needs to include the entire definition.

  • The ALTER statement only updates existing definitions and only needs to include the items to be updated, not the entire definition.

That's it for this part on making our data schemafull, in the next part, we'll explore how to make our data secure.

THE PLATFORM

Everything an application and its agents know. Five surfaces, one engine.

IN PRODUCTION

Trusted at scale. Samsung, Nvidia, Verizon, Tencent, and Walmart run on SurrealDB.

14,000+

Developers building on SurrealDB Cloud

4M+

Developers building on SurrealDB worldwide

FROM THE TEAMS

SurrealDB gives us a foundation where we can unify semantic search, knowledge graphs, and AI-driven decision making without stitching together multiple systems. Collapsing responsibility into SurrealDB has become our default engineering posture.
Justin Foley

VP of Engineering, Later

SurrealDB

The context and memory layer for AI agents

Database. Graphs, vectors, documents and relational data in one engine, in a single ACID transaction.
Agent Memory. Connects and retrieves context wherever your data lives, every fact carrying its source.
Cloud. Fully managed, in the cloud provider and region you choose.

Explore with AI

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