MariaDB Schema
function
The function block describes a function in a database schema.
function "positive" {
  schema = schema.public
  lang   = SQL
  arg "v" {
    type = integer
  }
  ...
}
function attributes
| Name | Required | Value | 
|---|---|---|
as | true | string | 
comment | false | string | 
data_access | false | 
  | 
deterministic | false | bool | 
return | true | Function return type can be one of: 
  | 
schema | true | Object reference to   | 
security | false | 
  | 
function blocks
function.arg
function.arg attributes
| Name | Required | Value | 
|---|---|---|
charset | false | string | 
collate | false | string | 
mode | false | 
  | 
type | true | Function argument type can be one of: 
  | 
function.arg constraints
| Constraint | Value | 
|---|---|
| Required | false | 
Require Name (e.g., function.arg "name" ) | true | 
| Repeatable | true | 
function constraints
| Constraint | Value | 
|---|---|
| Required | false | 
Require Name (e.g., function "name" ) | true | 
Allow Qualifier (e.g., function "schema" "name" ) | true | 
procedure
The procedure block describes a procedure in a database schema.
procedure "proc" {
  schema = schema.public
  lang   = SQL
  arg "a" {
    type = integer
  }
  ...
}
procedure attributes
| Name | Required | Value | 
|---|---|---|
as | true | string | 
comment | false | string | 
data_access | false | 
  | 
deterministic | false | bool | 
schema | true | Object reference to   | 
security | false | 
  | 
procedure blocks
procedure.arg
procedure.arg attributes
| Name | Required | Value | 
|---|---|---|
charset | false | string | 
collate | false | string | 
mode | false | 
  | 
type | true | Procedure argument type can be one of: 
  | 
procedure.arg constraints
| Constraint | Value | 
|---|---|
| Required | false | 
Require Name (e.g., procedure.arg "name" ) | true | 
| Repeatable | true | 
procedure constraints
| Constraint | Value | 
|---|---|
| Required | false | 
Require Name (e.g., procedure "name" ) | true | 
Allow Qualifier (e.g., procedure "schema" "name" ) | true | 
schema
The schema block describes a database schema.
schema "public" {
  ...
}
schema attributes
| Name | Required | Value | 
|---|---|---|
charset | false | string | 
collate | false | string | 
collation | false | string | 
comment | false | string | 
name | false | string | 
schema constraints
| Constraint | Value | 
|---|---|
| Required | false | 
Require Name (e.g., schema "name" ) | true | 
| 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
  }
  ...
}
table attributes
| Name | Required | Value | 
|---|---|---|
auto_increment | false | Table auto increment can be one of: 
  | 
charset | false | string | 
collate | false | string | 
comment | false | string | 
engine | false | Table engine can be one of: 
  | 
schema | true | Object reference to   | 
system_versioned | false | bool | 
table blocks
table.check
table.check attributes
| Name | Required | Value | 
|---|---|---|
comment | false | string | 
enforced | false | bool | 
expr | true | string | 
table.check constraints
| Constraint | Value | 
|---|---|
| Required | false | 
| Require Name | false | 
| Repeatable | true | 
table.column
table.column attributes
| Name | Required | Value | 
|---|---|---|
as | false | string | 
auto_increment | false | bool | 
charset | false | string | 
collate | false | string | 
comment | false | string | 
default | false | Column default value can be one of: 
  | 
null | false | bool | 
on_update | false | Raw expression defined with   | 
srid | false | int | 
type | true | Column type can be one of: 
  | 
unsigned | false | bool | 
table.column blocks
table.column.as
table.column.as attributes
| Name | Required | Value | 
|---|---|---|
expr | true | string | 
type | false | 
  | 
table.column constraints
| Constraint | Value | 
|---|---|
| Required | false | 
Require Name (e.g., table.column "name" ) | true | 
| Mutually exclusive sets | [as (attribute), as (block)] | 
table.foreign_key
table.foreign_key attributes
| Name | Required | Value | 
|---|---|---|
columns | true | Foreign key columns can be one of: 
  | 
comment | false | string | 
on_delete | false | 
  | 
on_update | false | 
  | 
ref_columns | true | Foreign key reference columns can be one of: 
  | 
table.foreign_key constraints
| Constraint | Value | 
|---|---|
| Required | false | 
Require Name (e.g., table.foreign_key "name" ) | true | 
table.index
table.index attributes
| Name | Required | Value | 
|---|---|---|
columns | false | Index columns can be one of: 
  | 
comment | false | string | 
parser | false | Index parser can be one of: 
  | 
type | false | Index key type can be one of: 
  | 
unique | false | bool | 
table.index blocks
table.index.on
table.index.on attributes
| Name | Required | Value | 
|---|---|---|
column | false | Index columns can be one of: 
  | 
desc | false | bool | 
expr | false | string | 
prefix | false | int | 
table.index.on constraints
| Constraint | Value | 
|---|---|
| Required | false | 
| Require Name | false | 
| Repeatable | true | 
| Mutually exclusive sets | [column, expr] | 
table.index constraints
| Constraint | Value | 
|---|---|
| Required | false | 
Require Name (e.g., table.index "name" ) | true | 
| Mutually exclusive sets | [columns, on] | 
| One of required sets | [columns, on] | 
table.primary_key
table.primary_key attributes
| Name | Required | Value | 
|---|---|---|
columns | false | Primary key columns can be one of: 
  | 
comment | false | string | 
type | false | Primary key type can be one of: 
  | 
table.primary_key blocks
table.primary_key.on
table.primary_key.on attributes
| Name | Required | Value | 
|---|---|---|
column | true | Index columns can be one of: 
  | 
desc | false | bool | 
prefix | false | int | 
table.primary_key.on constraints
| Constraint | Value | 
|---|---|
| Required | false | 
| Require Name | false | 
| Repeatable | true | 
table.primary_key constraints
| Constraint | Value | 
|---|---|
| Required | false | 
| Require Name | false | 
| Mutually exclusive sets | [columns, on] | 
| One of required sets | [columns, on] | 
table constraints
| Constraint | Value | 
|---|---|
| Required | false | 
Require Name (e.g., table "name" ) | true | 
Allow Qualifier (e.g., table "schema" "name" ) | true | 
trigger
The trigger block describes a trigger on a table in a database schema.
trigger "trigger_orders_audit" {
  on = table.orders
  ...
}
trigger attributes
| Name | Required | Value | 
|---|---|---|
as | true | string | 
follows | false | Object reference to   | 
for | false | 
  | 
foreach | false | 
  | 
on | true | Object reference to   | 
precedes | false | Object reference to   | 
trigger blocks
trigger.after
trigger.after attributes
| Name | Required | Value | 
|---|---|---|
delete | false | bool | 
insert | false | bool | 
update | false | bool | 
trigger.after constraints
| Constraint | Value | 
|---|---|
| Required | false | 
| Require Name | false | 
| Mutually exclusive sets | [insert, delete, update] | 
| One of required sets | [insert, delete, update] | 
trigger.before
trigger.before attributes
| Name | Required | Value | 
|---|---|---|
delete | false | bool | 
insert | false | bool | 
update | false | bool | 
trigger.before constraints
| Constraint | Value | 
|---|---|
| Required | false | 
| Require Name | false | 
| Mutually exclusive sets | [insert, delete, update] | 
| One of required sets | [insert, delete, update] | 
trigger constraints
| Constraint | Value | 
|---|---|
| Required | false | 
Require Name (e.g., trigger "name" ) | true | 
| Repeatable | true | 
| 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
  }
  ...
}
view attributes
| Name | Required | Value | 
|---|---|---|
as | true | string | 
check_option | false | 
  | 
comment | false | string | 
depends_on | false | List of object references  | 
schema | true | Object reference to   | 
security | false | 
  | 
view blocks
view.column
view.column attributes
| Name | Required | Value | 
|---|---|---|
comment | false | string | 
null | false | bool | 
type | true | Column type can be one of: 
  | 
unsigned | false | bool | 
view.column constraints
| Constraint | Value | 
|---|---|
| Required | false | 
Require Name (e.g., view.column "name" ) | true | 
view constraints
| Constraint | Value | 
|---|---|
| Required | false | 
Require Name (e.g., view "name" ) | true | 
Allow Qualifier (e.g., view "schema" "name" ) | true |