Click here to sign up to SurrealDB Cloud

Back to top
Documentation SurrealQL Statements REMOVE statement

REMOVE statement

The REMOVE statement is used to remove resources such as databases, tables, indexes, events and more.
Similar to a SQL DROP statement.

Statement syntax

REMOVE [
	NAMESPACE @name
	| DATABASE @name
	| USER @name ON [ ROOT | NAMESPACE | DATABASE ]
	| LOGIN @name ON [ NAMESPACE | DATABASE ]
	| TOKEN @name ON [ NAMESPACE | DATABASE ]
	| SCOPE @name
	| TABLE @name
	| EVENT @name ON [ TABLE ] @table
	| FUNCTION fn::@name
	| FIELD @name ON [ TABLE ] @table
	| INDEX @name ON [ TABLE ] @table
	| PARAM $@name
]

Example usage

The following queries show an example of how to remove resources

REMOVE NAMESPACE surrealdb;

REMOVE DATABASE blog;

REMOVE LOGIN writer ON NAMESPACE;

REMOVE USER writer ON NAMESPACE;

REMOVE TOKEN writer_token ON NAMESPACE;

REMOVE SCOPE documentation;

REMOVE TABLE article;

REMOVE EVENT new_post ON TABLE article;

REMOVE FUNCTION fn::update_author;

-- Only works for Schemaful tables (i.e. tables with a schema)
REMOVE FIELD tags ON TABLE article;

REMOVE INDEX authors ON TABLE article;

REMOVE PARAM $author;