Overview
DEFINE statement
The DEFINE statement can be used to specify authentication access and behaviour, global parameters, table configurations, table events, schema definitions, and indexes.
SurrealQL Syntax
DEFINE [
NAMESPACE @name
| DATABASE @name
| USER @name ON [ ROOT | NAMESPACE | DATABASE ] [ PASSWORD @pass | PASSHASH @hash ] ROLES @roles
| TOKEN @name ON [ NAMESPACE | DATABASE | SCOPE @scope ] TYPE @type VALUE @value
| SCOPE @name
[ SESSION @duration ]
[ SIGNUP @expression ]
[ SIGNIN @expression ]
| TABLE @name
[ DROP ]
[ SCHEMAFULL | SCHEMALESS ]
[ AS SELECT @projections
FROM @tables
[ WHERE @condition ]
[ GROUP [ BY ] @groups ]
]
[ PERMISSIONS [ NONE | FULL
| FOR select @expression
| FOR create @expression
| FOR update @expression
| FOR delete @expression
] ]
| EVENT @name ON [ TABLE ] @table WHEN @expression THEN @expression
| FIELD @name ON [ TABLE ] @table
[ [ FLEXIBLE ] TYPE @type ]
[ VALUE @expression ]
[ ASSERT @expression ]
[ PERMISSIONS [ NONE | FULL
| FOR select @expression
| FOR create @expression
| FOR update @expression
| FOR delete @expression
] ]
| ANALYZER @name
[ TOKENIZERS @tokenizers ]
[ FILTERS @filters ]
| INDEX @name ON [ TABLE ] @table [ FIELDS | COLUMNS ] @fields
[ UNIQUE | SEARCH ANALYZER @analyzer [ BM25 [(@k1, @b)] ] [ HIGHLIGHTS ] ]
]