Skip to main content

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

NameRequiredValue
astruestring
depends_onfalse

List of object references

execute_asfalse

The execution context of the function can be one of:

  1. Raw expression defined with sql("expr")
  2. string
inlinefalsebool
langtrue

Function language can be one of:

  1. string
  2. enum (SQL, CRL)
null_callfalse

enum (CALLED, RETURNS_NULL)

returnfalse

Function return type can be one of:

  1. Schema type
  2. Raw expression defined with sql("expr")
  3. Object reference to type_alias
schematrue

Object reference to schema

schema_boundfalsebool

Blocks

function.arg

function.arg attributes
NameRequiredValue
defaultfalse

Function argument default value can be one of:

  1. bool
  2. string
  3. number
modefalse

Function argument mode can be one of:

  1. string
  2. enum (IN, INOUT, OUT)
readonlyfalsebool
typetrue

Function argument type can be one of:

  1. Schema type
  2. Raw expression defined with sql("expr")
  3. Object reference to type_alias
  4. Object reference to type_table
function.arg constraints
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue
Allow unknown blocksfalse
Allow unknown attributesfalse

function.return_table

function.return_table blocks

function.return_table.check

function.return_table.check attributes
NameRequiredValue
exprtruestring
function.return_table.check constraints
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue
Allow unknown blocksfalse
Allow unknown attributesfalse

function.return_table.column

function.return_table.column attributes
NameRequiredValue
asfalsestring
collatefalsestring
commentfalsestring
defaultfalse

Column default value can be one of:

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

Column type can be one of:

  1. Schema type
  2. Raw expression defined with sql("expr")
  3. Object reference to type_alias
function.return_table.column blocks

function.return_table.column.as

function.return_table.column.as attributes
NameRequiredValue
exprtruestring
typefalse

enum (PERSISTED)

function.return_table.column.as constraints
ConstraintValue
Requiredfalse
Require Namefalse
Repeatablefalse
Allow unknown blocksfalse
Allow unknown attributesfalse

function.return_table.column.identity

function.return_table.column.identity attributes
NameRequiredValue
incrementfalseint
seedfalseint
function.return_table.column.identity constraints
ConstraintValue
Requiredfalse
Require Namefalse
Repeatablefalse
Allow unknown blocksfalse
Allow unknown attributesfalse
function.return_table.column constraints
ConstraintValue
Requiredtrue
Require Nametrue
Repeatablefalse
Allow unknown blocksfalse
Allow unknown attributesfalse
Mutually exclusive sets[as (attribute), as (block)]

function.return_table.index

function.return_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
includefalse

Index included columns can be one of:

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

Index key type can be one of:

  1. string
  2. enum (COLUMNSTORE, HASH, HEAP, SPATIAL, XML)
uniquefalsebool
wherefalsestring
function.return_table.index blocks

function.return_table.index.on

function.return_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
opsfalse

Index operator class can be one of:

  1. string
  2. Raw expression defined with sql("expr")
function.return_table.index.on constraints
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue
Allow unknown blocksfalse
Allow unknown attributesfalse
Mutually exclusive sets[column, expr]
function.return_table.index constraints
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue
Allow unknown blocksfalse
Allow unknown attributesfalse
Mutually exclusive sets[columns, on]
One of required sets[columns, on]

function.return_table.primary_key

function.return_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
includefalse

Primary key included columns can be one of:

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

Index key type can be one of:

  1. string
  2. enum (HASH)
function.return_table.primary_key constraints
ConstraintValue
Requiredfalse
Require Namefalse
Repeatablefalse
Allow unknown blocksfalse
Allow unknown attributesfalse
function.return_table 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

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
depends_onfalse

List of object references

execute_asfalse

The execution context of the procedure can be one of:

  1. Raw expression defined with sql("expr")
  2. string
langtrue

Procedure language can be one of:

  1. string
  2. enum (SQL, CRL)
schematrue

Object reference to schema

Blocks

procedure.arg

procedure.arg attributes
NameRequiredValue
defaultfalse

Procedure argument default value can be one of:

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

Procedure argument mode can be one of:

  1. string
  2. enum (IN, INOUT, OUT)
readonlyfalsebool
typetrue

Procedure argument type can be one of:

  1. Schema type
  2. Raw expression defined with sql("expr")
  3. Object reference to type_alias
  4. Object reference to type_table
procedure.arg 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

schema

The schema block describes a database schema.

schema "public" {
...
}

Attributes

NameRequiredValue
namefalsestring

Constraints

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

sequence

The sequence block describes a sequence in a database schema.

sequence "name" {
schema = schema.public
type = int
increment = 3
min_value = 9
}

Attributes

NameRequiredValue
cachefalseint
cyclefalsebool
incrementfalseint
max_valuefalseint
min_valuefalseint
schematrue

Object reference to schema

startfalseint
typefalse

Sequence type can be one of:

  1. Schema type
  2. Object reference to type_alias

Constraints

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

table

The table block describes a table in a database schema.

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

Attributes

NameRequiredValue
commentfalsestring
depends_onfalse

List of object references

memory_optimizedfalsebool
schematrue

Object reference to schema

Blocks

table.check

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

table.column

table.column attributes
NameRequiredValue
asfalsestring
collatefalsestring
commentfalsestring
defaultfalse

Column default value can be one of:

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

Column type can be one of:

  1. Schema type
  2. Raw expression defined with sql("expr")
  3. Object reference to type_alias
table.column blocks

table.column.as

table.column.as attributes
NameRequiredValue
exprtruestring
typefalse

enum (PERSISTED)

table.column.as constraints
ConstraintValue
Requiredfalse
Require Namefalse
Repeatablefalse
Allow unknown blocksfalse
Allow unknown attributesfalse

table.column.identity

table.column.identity attributes
NameRequiredValue
incrementfalseint
seedfalseint
table.column.identity 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
includefalse

Index included columns can be one of:

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

Index key type can be one of:

  1. string
  2. enum (COLUMNSTORE, HASH, HEAP, SPATIAL, XML)
uniquefalsebool
wherefalsestring
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
opsfalse

Index operator class can be one of:

  1. string
  2. Raw expression defined with sql("expr")
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]
One of required 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
includefalse

Primary key included columns can be one of:

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

Index key type can be one of:

  1. string
  2. enum (HASH)
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
execute_asfalse

The execution context of the trigger can be one of:

  1. Raw expression defined with sql("expr")
  2. string
ontrue

Trigger on can be one of:

  1. Object reference to table
  2. Object reference to view
schema_boundfalsebool

Blocks

trigger.after

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

trigger.instead_of

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

Constraints

ConstraintValue
Requiredfalse
Require Nametrue
Allow Qualifierfalse
Repeatabletrue
Allow unknown blocksfalse
Allow unknown attributesfalse
Mutually exclusive sets[after, instead_of]
One of required sets[after, instead_of]

type_alias

Attributes

NameRequiredValue
nullfalsebool
schematrue

Object reference to schema

typetrue

Base type can be one of:

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

Constraints

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

type_table

Attributes

NameRequiredValue
schematrue

Object reference to schema

Blocks

type_table.check

type_table.check attributes
NameRequiredValue
exprtruestring
type_table.check constraints
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue
Allow unknown blocksfalse
Allow unknown attributesfalse

type_table.column

type_table.column attributes
NameRequiredValue
asfalsestring
collatefalsestring
commentfalsestring
defaultfalse

Column default value can be one of:

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

Column type can be one of:

  1. Schema type
  2. Raw expression defined with sql("expr")
  3. Object reference to type_alias
type_table.column blocks

type_table.column.as

type_table.column.as attributes
NameRequiredValue
exprtruestring
typefalse

enum (PERSISTED)

type_table.column.as constraints
ConstraintValue
Requiredfalse
Require Namefalse
Repeatablefalse
Allow unknown blocksfalse
Allow unknown attributesfalse

type_table.column.identity

type_table.column.identity attributes
NameRequiredValue
incrementfalseint
seedfalseint
type_table.column.identity constraints
ConstraintValue
Requiredfalse
Require Namefalse
Repeatablefalse
Allow unknown blocksfalse
Allow unknown attributesfalse
type_table.column constraints
ConstraintValue
Requiredtrue
Require Nametrue
Repeatablefalse
Allow unknown blocksfalse
Allow unknown attributesfalse
Mutually exclusive sets[as (attribute), as (block)]

type_table.index

type_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
includefalse

Index included columns can be one of:

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

Index key type can be one of:

  1. string
  2. enum (COLUMNSTORE, HASH, HEAP, SPATIAL, XML)
uniquefalsebool
wherefalsestring
type_table.index blocks

type_table.index.on

type_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
opsfalse

Index operator class can be one of:

  1. string
  2. Raw expression defined with sql("expr")
type_table.index.on constraints
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue
Allow unknown blocksfalse
Allow unknown attributesfalse
Mutually exclusive sets[column, expr]
type_table.index constraints
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue
Allow unknown blocksfalse
Allow unknown attributesfalse
Mutually exclusive sets[columns, on]
One of required sets[columns, on]

type_table.primary_key

type_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
includefalse

Primary key included columns can be one of:

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

Index key type can be one of:

  1. string
  2. enum (HASH)
type_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

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, LOCAL, CASCADED)

commentfalsestring
depends_onfalse

List of object references

schematrue

Object reference to schema

schema_boundfalsebool

Blocks

view.column

view.column attributes
NameRequiredValue
nullfalsebool
typetrue

Column type can be one of:

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

view.index

view.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
includefalse

Index included columns can be one of:

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

Index key type can be one of:

  1. string
  2. enum (COLUMNSTORE, HASH, HEAP, SPATIAL, XML)
uniquefalsebool
wherefalsestring
view.index blocks

view.index.on

view.index.on attributes
NameRequiredValue
columnfalse

Index columns can be one of:

  1. Object reference to column
  2. Object reference to table.column
descfalsebool
exprfalsestring
opsfalse

Index operator class can be one of:

  1. string
  2. Raw expression defined with sql("expr")
view.index.on constraints
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue
Allow unknown blocksfalse
Allow unknown attributesfalse
Mutually exclusive sets[column, expr]
view.index constraints
ConstraintValue
Requiredfalse
Require Nametrue
Repeatablefalse
Allow unknown blocksfalse
Allow unknown attributesfalse
Mutually exclusive sets[columns, on]
One of required sets[columns, on]

Constraints

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