SQL Server Schema
function
The function
block describes a function in a database schema.
function "positive" {
schema = schema.public
lang = SQL
arg "v" {
type = integer
}
...
}
Attributes
Name | Required | Value |
---|---|---|
as | true | string |
depends_on | false | List of object references |
execute_as | false | The execution context of the function can be one of:
|
inline | false | bool |
lang | true | Function language can be one of:
|
null_call | false |
|
return | false | Function return type can be one of:
|
schema | true | Object reference to |
schema_bound | false | bool |
Blocks
function.arg
function.arg
attributes
Name | Required | Value |
---|---|---|
default | false | Function argument default value can be one of:
|
mode | false | Function argument mode can be one of:
|
readonly | false | bool |
type | true | Function argument type can be one of:
|
function.arg
constraints
Constraint | Value |
---|---|
Required | false |
Require Name | false |
Repeatable | true |
Allow unknown blocks | false |
Allow unknown attributes | false |
function.return_table
function.return_table
blocks
function.return_table.check
function.return_table.check
attributes
Name | Required | Value |
---|---|---|
expr | true | string |
function.return_table.check
constraints
Constraint | Value |
---|---|
Required | false |
Require Name | false |
Repeatable | true |
Allow unknown blocks | false |
Allow unknown attributes | false |
function.return_table.column
function.return_table.column
attributes
Name | Required | Value |
---|---|---|
as | false | string |
collate | false | string |
comment | false | string |
default | false | Column default value can be one of:
|
null | false | bool |
type | true | Column type can be one of:
|
function.return_table.column
blocks
function.return_table.column.as
function.return_table.column.as
attributes
Name | Required | Value |
---|---|---|
expr | true | string |
type | false |
|
function.return_table.column.as
constraints
Constraint | Value |
---|---|
Required | false |
Require Name | false |
Repeatable | false |
Allow unknown blocks | false |
Allow unknown attributes | false |
function.return_table.column.identity
function.return_table.column.identity
attributes
Name | Required | Value |
---|---|---|
increment | false | int |
seed | false | int |
function.return_table.column.identity
constraints
Constraint | Value |
---|---|
Required | false |
Require Name | false |
Repeatable | false |
Allow unknown blocks | false |
Allow unknown attributes | false |
function.return_table.column
constraints
Constraint | Value |
---|---|
Required | true |
Require Name | true |
Repeatable | false |
Allow unknown blocks | false |
Allow unknown attributes | false |
Mutually exclusive sets | [as (attribute), as (block)] |
function.return_table.index
function.return_table.index
attributes
Name | Required | Value |
---|---|---|
columns | false | Index columns can be one of:
|
comment | false | string |
include | false | Index included columns can be one of:
|
nonclustered | false | bool |
type | false | Index key type can be one of:
|
unique | false | bool |
where | false | string |
function.return_table.index
blocks
function.return_table.index.on
function.return_table.index.on
attributes
Name | Required | Value |
---|---|---|
column | false | Index columns can be one of:
|
desc | false | bool |
expr | false | string |
ops | false | Index operator class can be one of:
|
function.return_table.index.on
constraints
Constraint | Value |
---|---|
Required | false |
Require Name | false |
Repeatable | true |
Allow unknown blocks | false |
Allow unknown attributes | false |
Mutually exclusive sets | [column, expr] |
function.return_table.index
constraints
Constraint | Value |
---|---|
Required | false |
Require Name | false |
Repeatable | true |
Allow unknown blocks | false |
Allow unknown attributes | false |
Mutually exclusive sets | [columns, on] |
One of required sets | [columns, on] |
function.return_table.primary_key
function.return_table.primary_key
attributes
Name | Required | Value |
---|---|---|
columns | true | Primary key columns can be one of:
|
comment | false | string |
include | false | Primary key included columns can be one of:
|
nonclustered | false | bool |
type | false | Index key type can be one of:
|
function.return_table.primary_key
constraints
Constraint | Value |
---|---|
Required | false |
Require Name | false |
Repeatable | false |
Allow unknown blocks | false |
Allow unknown attributes | false |
function.return_table
constraints
Constraint | Value |
---|---|
Required | false |
Require Name | true |
Repeatable | false |
Allow unknown blocks | false |
Allow unknown attributes | false |
Constraints
Constraint | Value |
---|---|
Required | false |
Require Name | true |
Allow Qualifier | true |
Repeatable | false |
Allow unknown blocks | false |
Allow unknown attributes | false |
procedure
The procedure
block describes a procedure in a database schema.
procedure "proc" {
schema = schema.public
lang = SQL
arg "a" {
type = integer
}
...
}
Attributes
Name | Required | Value |
---|---|---|
as | true | string |
depends_on | false | List of object references |
execute_as | false | The execution context of the procedure can be one of:
|
lang | true | Procedure language can be one of:
|
schema | true | Object reference to |
Blocks
procedure.arg
procedure.arg
attributes
Name | Required | Value |
---|---|---|
default | false | Procedure argument default value can be one of:
|
mode | false | Procedure argument mode can be one of:
|
readonly | false | bool |
type | true | Procedure argument type can be one of:
|
procedure.arg
constraints
Constraint | Value |
---|---|
Required | false |
Require Name | true |
Repeatable | false |
Allow unknown blocks | false |
Allow unknown attributes | false |
Constraints
Constraint | Value |
---|---|
Required | false |
Require Name | true |
Allow Qualifier | true |
Repeatable | false |
Allow unknown blocks | false |
Allow unknown attributes | false |
schema
The schema
block describes a database schema.
schema "public" {
...
}
Attributes
Name | Required | Value |
---|---|---|
name | false | string |
Constraints
Constraint | Value |
---|---|
Required | false |
Require Name | true |
Allow Qualifier | false |
Repeatable | false |
Allow unknown blocks | false |
Allow unknown attributes | false |
sequence
The sequence
block describes a sequence in a database schema.
sequence "name" {
schema = schema.public
type = int
increment = 3
min_value = 9
}
Attributes
Name | Required | Value |
---|---|---|
cache | false | int |
cycle | false | bool |
increment | false | int |
max_value | false | int |
min_value | false | int |
schema | true | Object reference to |
start | false | int |
type | false | Sequence type can be one of:
|
Constraints
Constraint | Value |
---|---|
Required | false |
Require Name | true |
Allow Qualifier | true |
Repeatable | false |
Allow unknown blocks | false |
Allow unknown attributes | false |
table
The table
block describes a table in a database schema.
table "users" {
schema = schema.public
column "id" {
type = int
}
...
}
Attributes
Name | Required | Value |
---|---|---|
comment | false | string |
depends_on | false | List of object references |
memory_optimized | false | bool |
schema | true | Object reference to |
Blocks
table.check
table.check
attributes
Name | Required | Value |
---|---|---|
expr | true | string |
table.check
constraints
Constraint | Value |
---|---|
Required | false |
Require Name | false |
Repeatable | true |
Allow unknown blocks | false |
Allow unknown attributes | false |
table.column
table.column
attributes
Name | Required | Value |
---|---|---|
as | false | string |
collate | false | string |
comment | false | string |
default | false | Column default value can be one of:
|
null | false | bool |
type | true | Column type can be one of:
|
table.column
blocks
table.column.as
table.column.as
attributes
Name | Required | Value |
---|---|---|
expr | true | string |
type | false |
|
table.column.as
constraints
Constraint | Value |
---|---|
Required | false |
Require Name | false |
Repeatable | false |
Allow unknown blocks | false |
Allow unknown attributes | false |
table.column.identity
table.column.identity
attributes
Name | Required | Value |
---|---|---|
increment | false | int |
seed | false | int |
table.column.identity
constraints
Constraint | Value |
---|---|
Required | false |
Require Name | false |
Repeatable | false |
Allow unknown blocks | false |
Allow unknown attributes | false |
table.column
constraints
Constraint | Value |
---|---|
Required | false |
Require Name | true |
Repeatable | false |
Allow unknown blocks | false |
Allow unknown attributes | false |
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 | true |
Repeatable | false |
Allow unknown blocks | false |
Allow unknown attributes | false |
table.index
table.index
attributes
Name | Required | Value |
---|---|---|
columns | false | Index columns can be one of:
|
comment | false | string |
include | false | Index included columns can be one of:
|
nonclustered | false | bool |
type | false | Index key type can be one of:
|
unique | false | bool |
where | false | string |
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 |
ops | false | Index operator class can be one of:
|
table.index.on
constraints
Constraint | Value |
---|---|
Required | false |
Require Name | false |
Repeatable | true |
Allow unknown blocks | false |
Allow unknown attributes | false |
Mutually exclusive sets | [column, expr] |
table.index
constraints
Constraint | Value |
---|---|
Required | false |
Require Name | true |
Repeatable | false |
Allow unknown blocks | false |
Allow unknown attributes | false |
Mutually exclusive sets | [columns, on] |
One of required sets | [columns, on] |
table.primary_key
table.primary_key
attributes
Name | Required | Value |
---|---|---|
columns | true | Primary key columns can be one of:
|
comment | false | string |
include | false | Primary key included columns can be one of:
|
nonclustered | false | bool |
type | false | Index key type can be one of:
|
table.primary_key
constraints
Constraint | Value |
---|---|
Required | false |
Require Name | false |
Repeatable | false |
Allow unknown blocks | false |
Allow unknown attributes | false |
Constraints
Constraint | Value |
---|---|
Required | false |
Require Name | true |
Allow Qualifier | true |
Repeatable | false |
Allow unknown blocks | false |
Allow unknown attributes | false |
trigger
The trigger
block describes a trigger on a table in a database schema.
trigger "trigger_orders_audit" {
on = table.orders
...
}
Attributes
Name | Required | Value |
---|---|---|
as | true | string |
execute_as | false | The execution context of the trigger can be one of:
|
on | true | Trigger on can be one of: |
schema_bound | false | bool |
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 |
Repeatable | false |
Allow unknown blocks | false |
Allow unknown attributes | false |
One of required sets | [insert, delete, update] |
trigger.instead_of
trigger.instead_of
attributes
Name | Required | Value |
---|---|---|
delete | false | bool |
insert | false | bool |
update | false | bool |
trigger.instead_of
constraints
Constraint | Value |
---|---|
Required | false |
Require Name | false |
Repeatable | false |
Allow unknown blocks | false |
Allow unknown attributes | false |
One of required sets | [insert, delete, update] |
Constraints
Constraint | Value |
---|---|
Required | false |
Require Name | true |
Allow Qualifier | false |
Repeatable | true |
Allow unknown blocks | false |
Allow unknown attributes | false |
Mutually exclusive sets | [after, instead_of] |
One of required sets | [after, instead_of] |
type_alias
Attributes
Name | Required | Value |
---|---|---|
null | false | bool |
schema | true | Object reference to |
type | true | Base type can be one of:
|
Constraints
Constraint | Value |
---|---|
Required | false |
Require Name | true |
Allow Qualifier | true |
Repeatable | false |
Allow unknown blocks | false |
Allow unknown attributes | false |
type_table
Attributes
Name | Required | Value |
---|---|---|
schema | true | Object reference to |
Blocks
type_table.check
type_table.check
attributes
Name | Required | Value |
---|---|---|
expr | true | string |
type_table.check
constraints
Constraint | Value |
---|---|
Required | false |
Require Name | false |
Repeatable | true |
Allow unknown blocks | false |
Allow unknown attributes | false |
type_table.column
type_table.column
attributes
Name | Required | Value |
---|---|---|
as | false | string |
collate | false | string |
comment | false | string |
default | false | Column default value can be one of:
|
null | false | bool |
type | true | Column type can be one of:
|
type_table.column
blocks
type_table.column.as
type_table.column.as
attributes
Name | Required | Value |
---|---|---|
expr | true | string |
type | false |
|
type_table.column.as
constraints
Constraint | Value |
---|---|
Required | false |
Require Name | false |
Repeatable | false |
Allow unknown blocks | false |
Allow unknown attributes | false |
type_table.column.identity
type_table.column.identity
attributes
Name | Required | Value |
---|---|---|
increment | false | int |
seed | false | int |
type_table.column.identity
constraints
Constraint | Value |
---|---|
Required | false |
Require Name | false |
Repeatable | false |
Allow unknown blocks | false |
Allow unknown attributes | false |
type_table.column
constraints
Constraint | Value |
---|---|
Required | true |
Require Name | true |
Repeatable | false |
Allow unknown blocks | false |
Allow unknown attributes | false |
Mutually exclusive sets | [as (attribute), as (block)] |
type_table.index
type_table.index
attributes
Name | Required | Value |
---|---|---|
columns | false | Index columns can be one of:
|
comment | false | string |
include | false | Index included columns can be one of:
|
nonclustered | false | bool |
type | false | Index key type can be one of:
|
unique | false | bool |
where | false | string |
type_table.index
blocks
type_table.index.on
type_table.index.on
attributes
Name | Required | Value |
---|---|---|
column | false | Index columns can be one of:
|
desc | false | bool |
expr | false | string |
ops | false | Index operator class can be one of:
|
type_table.index.on
constraints
Constraint | Value |
---|---|
Required | false |
Require Name | false |
Repeatable | true |
Allow unknown blocks | false |
Allow unknown attributes | false |
Mutually exclusive sets | [column, expr] |
type_table.index
constraints
Constraint | Value |
---|---|
Required | false |
Require Name | false |
Repeatable | true |
Allow unknown blocks | false |
Allow unknown attributes | false |
Mutually exclusive sets | [columns, on] |
One of required sets | [columns, on] |
type_table.primary_key
type_table.primary_key
attributes
Name | Required | Value |
---|---|---|
columns | true | Primary key columns can be one of:
|
comment | false | string |
include | false | Primary key included columns can be one of:
|
nonclustered | false | bool |
type | false | Index key type can be one of:
|
type_table.primary_key
constraints
Constraint | Value |
---|---|
Required | false |
Require Name | false |
Repeatable | false |
Allow unknown blocks | false |
Allow unknown attributes | false |
Constraints
Constraint | Value |
---|---|
Required | false |
Require Name | true |
Allow Qualifier | true |
Repeatable | false |
Allow unknown blocks | false |
Allow unknown attributes | false |
view
The view
block describes a view in a database schema.
view "clean_users" {
schema = schema.public
column "id" {
type = int
}
...
}
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 |
schema_bound | false | bool |
Blocks
view.column
view.column
attributes
Name | Required | Value |
---|---|---|
null | false | bool |
type | true | Column type can be one of:
|
view.column
constraints
Constraint | Value |
---|---|
Required | false |
Require Name | true |
Repeatable | false |
Allow unknown blocks | false |
Allow unknown attributes | false |
view.index
view.index
attributes
Name | Required | Value |
---|---|---|
columns | false | Index columns can be one of:
|
comment | false | string |
include | false | Index included columns can be one of:
|
nonclustered | false | bool |
type | false | Index key type can be one of:
|
unique | false | bool |
where | false | string |
view.index
blocks
view.index.on
view.index.on
attributes
Name | Required | Value |
---|---|---|
column | false | Index columns can be one of:
|
desc | false | bool |
expr | false | string |
ops | false | Index operator class can be one of:
|
view.index.on
constraints
Constraint | Value |
---|---|
Required | false |
Require Name | false |
Repeatable | true |
Allow unknown blocks | false |
Allow unknown attributes | false |
Mutually exclusive sets | [column, expr] |
view.index
constraints
Constraint | Value |
---|---|
Required | false |
Require Name | true |
Repeatable | false |
Allow unknown blocks | false |
Allow unknown attributes | false |
Mutually exclusive sets | [columns, on] |
One of required sets | [columns, on] |
Constraints
Constraint | Value |
---|---|
Required | false |
Require Name | true |
Allow Qualifier | true |
Repeatable | false |
Allow unknown blocks | false |
Allow unknown attributes | false |