Skip to main content

MariaDB Schema

function

The function block describes a function in a database schema.

function "positive" {
schema = schema.public
lang = SQL
arg "v" {
type = integer
}
...
}

Attributes

NameRequiredValue
astruestring
commentfalsestring
data_accessfalse

enum (CONTAINS_SQL, NO_SQL, READS_SQL_DATA, MODIFIES_SQL_DATA)

deterministicfalsebool
returntrue

Function return type can be one of:

  1. Schema type
  2. Raw expression defined with sql("expr")
schematrue

Object reference to schema

securityfalse

enum (DEFINER, INVOKER)

Blocks

function.arg

function.arg attributes
NameRequiredValue
charsetfalsestring
collatefalsestring
modefalse

enum (IN)

typetrue

Function argument type can be one of:

  1. Schema type
  2. Raw expression defined with sql("expr")
function.arg constraints
ConstraintValue
Requiredfalse
Require Nametrue
Repeatabletrue
Allow unknown blocksfalse
Allow unknown attributesfalse

Constraints

ConstraintValue
Requiredfalse
Require Nametrue
Allow Qualifiertrue
Repeatablefalse
Allow unknown blocksfalse
Allow unknown attributesfalse

procedure

The procedure block describes a procedure in a database schema.

procedure "proc" {
schema = schema.public
lang = SQL
arg "a" {
type = integer
}
...
}

Attributes

NameRequiredValue
astruestring
commentfalsestring
data_accessfalse

enum (CONTAINS_SQL, NO_SQL, READS_SQL_DATA, MODIFIES_SQL_DATA)

deterministicfalsebool
schematrue

Object reference to schema

securityfalse

enum (DEFINER, INVOKER)

Blocks

procedure.arg

procedure.arg attributes
NameRequiredValue
charsetfalsestring
collatefalsestring
modefalse

enum (IN, OUT, INOUT)

typetrue

Procedure argument type can be one of:

  1. Schema type
  2. Raw expression defined with sql("expr")
procedure.arg constraints
ConstraintValue
Requiredfalse
Require Nametrue
Repeatabletrue
Allow unknown blocksfalse
Allow unknown attributesfalse

Constraints

ConstraintValue
Requiredfalse
Require Nametrue
Allow Qualifiertrue
Repeatablefalse
Allow unknown blocksfalse
Allow unknown attributesfalse

schema

The schema block describes a database schema.

schema "public" {
...
}

Attributes

NameRequiredValue
charsetfalsestring
collatefalsestring
collationfalsestring
commentfalsestring
namefalsestring

Constraints

ConstraintValue
Requiredfalse
Require Nametrue
Allow Qualifierfalse
Repeatablefalse
Allow unknown blocksfalse
Allow unknown attributesfalse
Mutually exclusive sets[collate, collation]

table

The table block describes a table in a database schema.

table "users" {
schema = schema.public
column "id" {
type = int
}
...
}

Attributes

NameRequiredValue
auto_incrementfalseint
charsetfalsestring
collatefalsestring
commentfalsestring
enginefalse

Table engine can be one of:

  1. string
  2. enum (InnoDB, MyISAM, Memory, CSV, NDB)
schematrue

Object reference to schema

system_versionedfalsebool

Blocks

table.check

table.check attributes
NameRequiredValue
commentfalsestring
enforcedfalsebool
exprtruestring
table.check constraints
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue
Allow unknown blocksfalse
Allow unknown attributesfalse

table.column

table.column attributes
NameRequiredValue
asfalsestring
auto_incrementfalsebool
charsetfalsestring
collatefalsestring
commentfalsestring
defaultfalse

Column default value can be one of:

  1. bool
  2. string
  3. number
  4. Raw expression defined with sql("expr")
nullfalsebool
on_updatefalse

Raw expression defined with sql("expr")

typetrue

Column type can be one of:

  1. Schema type
  2. Raw expression defined with sql("expr")
unsignedfalsebool
table.column blocks

table.column.as

table.column.as attributes
NameRequiredValue
exprtruestring
typefalse

enum (VIRTUAL, STORED)

table.column.as constraints
ConstraintValue
Requiredfalse
Require Namefalse
Repeatablefalse
Allow unknown blocksfalse
Allow unknown attributesfalse
table.column constraints
ConstraintValue
Requiredfalse
Require Nametrue
Repeatablefalse
Allow unknown blocksfalse
Allow unknown attributesfalse
Mutually exclusive sets[as (attribute), as (block)]

table.foreign_key

table.foreign_key attributes
NameRequiredValue
columnstrue

Foreign key columns can be one of:

  1. List of object reference to column
  2. List of object reference to table.column
commentfalsestring
on_deletefalse

enum (NO_ACTION, RESTRICT, CASCADE, SET_NULL, SET_DEFAULT)

on_updatefalse

enum (NO_ACTION, RESTRICT, CASCADE, SET_NULL, SET_DEFAULT)

ref_columnstrue

Foreign key reference columns can be one of:

  1. List of object reference to column
  2. List of object reference to table.column
table.foreign_key constraints
ConstraintValue
Requiredfalse
Require Nametrue
Repeatablefalse
Allow unknown blocksfalse
Allow unknown attributesfalse

table.index

table.index attributes
NameRequiredValue
columnsfalse

Index columns can be one of:

  1. List of object reference to column
  2. List of object reference to table.column
commentfalsestring
parserfalse

Index parser can be one of:

  1. string
  2. enum (ngram, mecab)
typefalse

Index key type can be one of:

  1. string
  2. enum (BTREE, HASH, FULLTEXT, SPATIAL)
uniquefalsebool
table.index blocks

table.index.on

table.index.on attributes
NameRequiredValue
columnfalse

Index columns can be one of:

  1. Object reference to column
  2. Object reference to table.column
descfalsebool
exprfalsestring
prefixfalseint
table.index.on constraints
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue
Allow unknown blocksfalse
Allow unknown attributesfalse
Mutually exclusive sets[column, expr]
table.index constraints
ConstraintValue
Requiredfalse
Require Nametrue
Repeatablefalse
Allow unknown blocksfalse
Allow unknown attributesfalse
Mutually exclusive sets[columns, on]

table.primary_key

table.primary_key attributes
NameRequiredValue
columnstrue

Primary key columns can be one of:

  1. List of object reference to column
  2. List of object reference to table.column
commentfalsestring
typefalse

Primary key type can be one of:

  1. string
  2. enum (BTREE, HASH, FULLTEXT, SPATIAL)
table.primary_key constraints
ConstraintValue
Requiredfalse
Require Namefalse
Repeatablefalse
Allow unknown blocksfalse
Allow unknown attributesfalse

Constraints

ConstraintValue
Requiredfalse
Require Nametrue
Allow Qualifiertrue
Repeatablefalse
Allow unknown blocksfalse
Allow unknown attributesfalse

trigger

The trigger block describes a trigger on a table in a database schema.

trigger "trigger_orders_audit" {
on = table.orders
...
}

Attributes

NameRequiredValue
astruestring
followsfalse

Object reference to trigger

forfalse

enum (ROW)

foreachfalse

enum (ROW)

ontrue

Object reference to table

precedesfalse

Object reference to trigger

Blocks

trigger.after

trigger.after attributes
NameRequiredValue
deletefalsebool
insertfalsebool
updatefalsebool
trigger.after constraints
ConstraintValue
Requiredfalse
Require Namefalse
Repeatablefalse
Allow unknown blocksfalse
Allow unknown attributesfalse
Mutually exclusive sets[insert, delete, update]
One of required sets[insert, delete, update]

trigger.before

trigger.before attributes
NameRequiredValue
deletefalsebool
insertfalsebool
updatefalsebool
trigger.before constraints
ConstraintValue
Requiredfalse
Require Namefalse
Repeatablefalse
Allow unknown blocksfalse
Allow unknown attributesfalse
Mutually exclusive sets[insert, delete, update]
One of required sets[insert, delete, update]

Constraints

ConstraintValue
Requiredfalse
Require Nametrue
Allow Qualifierfalse
Repeatabletrue
Allow unknown blocksfalse
Allow unknown attributesfalse
Mutually exclusive sets[foreach, for], [follows, precedes], [before, after]
One of required sets[before, after]

view

The view block describes a view in a database schema.

view "clean_users" {
schema = schema.public
column "id" {
type = int
}
...
}

Attributes

NameRequiredValue
astruestring
check_optionfalse

enum (LOCAL, CASCADED)

commentfalsestring
depends_onfalse

List of object references

schematrue

Object reference to schema

securityfalse

enum (DEFINER, INVOKER)

Blocks

view.column

view.column attributes
NameRequiredValue
commentfalsestring
nullfalsebool
typetrue

Column type can be one of:

  1. Schema type
  2. Raw expression defined with sql("expr")
unsignedfalsebool
view.column constraints
ConstraintValue
Requiredfalse
Require Nametrue
Repeatablefalse
Allow unknown blocksfalse
Allow unknown attributesfalse

Constraints

ConstraintValue
Requiredfalse
Require Nametrue
Allow Qualifiertrue
Repeatablefalse
Allow unknown blocksfalse
Allow unknown attributesfalse