MariaDB Schema
data
The data block defines seed/lookup data for a table.
data {
table = table.countries
rows = [
{ code = "US", name = "United States" },
{ code = "CA", name = "Canada" },
]
}
data attributes
| Name | Required | Value |
|---|---|---|
rows | true | Any value |
table | true | Object reference to |
data constraints
| Constraint | Value |
|---|---|
| Required | false |
| Require Name | false |
| Repeatable | true |
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.annotation
function.annotation constraints
| Constraint | Value |
|---|---|
| Required | false |
| Require Name | false |
| Allow unknown blocks | true |
| Allow unknown attributes | true |
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 |
permission
The permission block describes permissions (privileges) granted on database objects.
permission {
to = "app_user"
for = table.users
privileges = [SELECT]
}
permission {
to = role.admin
for = schema.public
privileges = [ALL]
grantable = true
}
permission attributes
| Name | Required | Value |
|---|---|---|
for | true | Permission target resource can be one of:
|
grantable | false | bool |
privileges | true | List of strings or/and |
to | true | Permission grantee can be one of: |
permission constraints
| Constraint | Value |
|---|---|
| Required | false |
| Require Name | false |
| Repeatable | 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.annotation
procedure.annotation constraints
| Constraint | Value |
|---|---|
| Required | false |
| Require Name | false |
| Allow unknown blocks | true |
| Allow unknown attributes | true |
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 |
role
The role block describes a database role.
role "admin" {
password_expired = false
password_lifetime = 90
max_questions = 1000
max_updates = 500
max_connections = 10
max_user_connections = 5
auth_plugin = "mysql_native_password"
member_of = [role.dba]
}
role attributes
| Name | Required | Value |
|---|---|---|
auth_plugin | false | string |
comment | false | string |
max_connections | false | int |
max_questions | false | int |
max_updates | false | int |
max_user_connections | false | int |
member_of | false | List of object reference to |
password_expired | false | bool |
password_lifetime | false | int |
role constraints
| Constraint | Value |
|---|---|
| Required | false |
Require Name (e.g., role "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 blocks
schema.annotation
schema.annotation constraints
| Constraint | Value |
|---|---|
| Required | false |
| Require Name | false |
| Allow unknown blocks | true |
| Allow unknown attributes | true |
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:
|
renamed_from | false | string |
schema | true | Object reference to |
system_versioned | false | bool |
table blocks
table.annotation
table.annotation constraints
| Constraint | Value |
|---|---|
| Required | false |
| Require Name | false |
| Allow unknown blocks | true |
| Allow unknown attributes | true |
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 |
renamed_from | false | string |
srid | false | int |
type | true | Column type can be one of:
|
unsigned | false | bool |