PostgreSQL Schema
aggregate
aggregate attributes
| Name | Required | Value |
|---|---|---|
comment | false | string |
depends_on | false | List of object references |
initial_value | false | Aggregate initial value can be one of:
|
parallel | false |
|
schema | true | Object reference to |
state_func | true | Object reference to |
state_type | true | Aggregate state type can be one of: |
aggregate blocks
aggregate.arg
aggregate.arg attributes
| Name | Required | Value |
|---|---|---|
default | false | Aggregate argument default value can be one of:
|
mode | false | Aggregate argument mode can be one of:
|
type | true | Aggregate argument type can be one of: |
aggregate.arg constraints
| Constraint | Value |
|---|---|
| Required | false |
| Require Name | false |
| Repeatable | true |
aggregate constraints
| Constraint | Value |
|---|---|
| Required | false |
Require Name (e.g., aggregate "name" ) | true |
Allow Qualifier (e.g., aggregate "schema" "name" ) | true |
| Repeatable | true |
composite
The composite block describes a composite type in the schema.
composite "address" {
schema = schema.public
field "street" {
type = text
}
field "city" {
type = text
}
}
composite attributes
| Name | Required | Value |
|---|---|---|
comment | false | string |
name | false | string |
schema | true | Object reference to |
composite blocks
composite.field
composite.field attributes
| Name | Required | Value |
|---|---|---|
collate | false | string |
type | true | Field type can be one of: |
composite.field constraints
| Constraint | Value |
|---|---|
| Required | true |
Require Name (e.g., composite.field "name" ) | true |
composite constraints
| Constraint | Value |
|---|---|
| Required | false |
Require Name (e.g., composite "name" ) | true |
Allow Qualifier (e.g., composite "schema" "name" ) | true |
domain
The domain block describes a DOMAIN type in the schema.
domain "us_postal_code" {
schema = schema.public
type = text
null = true
check "us_postal_code_check" {
expr = "..."
}
}
domain attributes
| Name | Required | Value |
|---|---|---|
comment | false | string |
default | false | Domain default value can be one of:
|
name | false | string |
null | false | bool |
schema | true | Object reference to |
type | true | Domain type can be one of: |
domain blocks
domain.check
domain.check attributes
| Name | Required | Value |
|---|---|---|
comment | false | string |
expr | true | string |
domain.check constraints
| Constraint | Value |
|---|---|
| Required | false |
| Require Name | false |
| Repeatable | true |
domain constraints
| Constraint | Value |
|---|---|
| Required | false |
Require Name (e.g., domain "name" ) | true |
Allow Qualifier (e.g., domain "schema" "name" ) | true |
enum
The enum block describes an ENUM type in the schema.
enum "status" {
schema = schema.test
values = ["on", "off"]
}
enum attributes
| Name | Required | Value |
|---|---|---|
comment | false | string |
name | false | string |
schema | true | Object reference to |
values | true | List of strings |
enum constraints
| Constraint | Value |
|---|---|
| Required | false |
Require Name (e.g., enum "name" ) | true |
Allow Qualifier (e.g., enum "schema" "name" ) | true |
event_trigger
The event_trigger block describes an event trigger in the database.
event_trigger "record_table_creation" {
on = ddl_command_start
tags = ["CREATE TABLE"]
execute = function.record_table_creation
}
event_trigger attributes
| Name | Required | Value |
|---|---|---|
comment | false | string |
execute | true | Object reference to |
on | true | Event trigger on can be one of:
|
tags | false | List of strings |
event_trigger constraints
| Constraint | Value |
|---|---|
| Required | false |
Require Name (e.g., event_trigger "name" ) | true |
extension
The extension block describes an extension in the database.
extension "postgis" {
schema = schema.public
}
extension "pgcrypto" {
schema = schema.public
version = "1.3"
comment = "cryptographic functions"
}
extension attributes
| Name and description | Required | Value |
|---|---|---|
comment | false | string |
The | false | List of object reference to |
name | false | string |
schema | false | Object reference to |
version | false | string |
extension constraints
| Constraint | Value |
|---|---|
| Required | false |
Require Name (e.g., extension "name" ) | true |
foreign_table
foreign_table attributes
| Name | Required | Value |
|---|---|---|
comment | false | string |
depends_on | false | List of object references |
options | false | map |
schema | true | Object reference to |
server | true | The reference or a name of an existing foreign server to use for the foreign table can be one of:
|
foreign_table blocks
foreign_table.check
foreign_table.check attributes
| Name | Required | Value |
|---|---|---|
comment | false | string |
expr | true | string |
foreign_table.check constraints
| Constraint | Value |
|---|---|
| Required | false |
| Require Name | false |
| Repeatable | true |
foreign_table.column
foreign_table.column attributes
| Name | Required | Value |
|---|---|---|
as | false | string |
collate | false | string |
comment | false | string |
null | false | bool |
options | false | map |
type | true | Column type can be one of: |
foreign_table.column blocks
foreign_table.column.as
foreign_table.column.as attributes
| Name | Required | Value |
|---|---|---|
expr | true | string |
type | false |
|
foreign_table.column constraints
| Constraint | Value |
|---|---|
| Required | false |
Require Name (e.g., foreign_table.column "name" ) | true |
| Mutually exclusive sets | [as (attribute), as (block)] |
foreign_table constraints
| Constraint | Value |
|---|---|
| Required | false |
Require Name (e.g., foreign_table "name" ) | true |
Allow Qualifier (e.g., foreign_table "schema" "name" ) | 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 |
depends_on | false | List of object references |
lang | true | Function language can be one of:
|
leakproof | false | bool |
parallel | false |
|
return | false | Function return type can be one of: |
return_set | false | Function return_set type can be one of: |
schema | true | Object reference to |
security | false |
|
strict | false | bool |
volatility | false |
|
function 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:
|
type | true | Function argument type can be one of: |
function.arg constraints
| Constraint | Value |
|---|---|
| Required | false |
| Require Name | false |
| Repeatable | true |
function.config_params
The config_params block describes the configuration parameters to be set when the function is entered.
config_params {
search_path = "public"
work_mem = "64MB"
client_min_messages = "warning"
// Other custom configuration parameters.
}
function.config_params attributes
| Name | Required | Value |
|---|---|---|
schema | false | string |
search_path | false | string |
statement_timeout | false | string |
work_mem | false | string |
function.config_params constraints
| Constraint | Value |
|---|---|
| Required | false |
| Require Name | false |
| Allow unknown attributes | true |
function.return_table
function.return_table blocks
function.return_table.column
function.return_table.column attributes
| Name | Required | Value |
|---|---|---|
type | true | Function return_table column type can be one of: |
function.return_table.column constraints
| Constraint | Value |
|---|---|
| Required | true |
Require Name (e.g., function.return_table.column "name" ) | true |
function constraints
| Constraint | Value |
|---|---|
| Required | false |
Require Name (e.g., function "name" ) | true |
Allow Qualifier (e.g., function "schema" "name" ) | true |
| Repeatable | true |
| Mutually exclusive sets | [return, return_set, return_table] |
materialized
The materialized block describes a materialized view in a database schema.
materialized "name" {
schema = schema.public
column "total" {
null = true
type = numeric
}
...
}
materialized attributes
| Name | Required | Value |
|---|---|---|
as | true | string |
comment | false | string |
depends_on | false | List of object references |
schema | true | Object reference to |
materialized blocks
materialized.column
materialized.column attributes
| Name | Required | Value |
|---|---|---|
comment | false | string |
null | false | bool |
type | true | Column type can be one of: |
materialized.column constraints
| Constraint | Value |
|---|---|
| Required | false |
Require Name (e.g., materialized.column "name" ) | true |
materialized.index
materialized.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:
|
nulls_distinct | false | bool |
page_per_range | false | int |
type | false | Index key type can be one of:
|
unique | false | bool |
where | false | string |
materialized.index blocks
materialized.index.on
materialized.index.on attributes
| Name | Required | Value |
|---|---|---|
column | false | Index columns can be one of:
|
desc | false | bool |
expr | false | string |
nulls_first | false | bool |
nulls_last | false | bool |
ops | false | Index operator class can be one of:
|
materialized.index.on constraints
| Constraint | Value |
|---|---|
| Required | false |
| Require Name | false |
| Repeatable | true |
| Mutually exclusive sets | [column, expr], [nulls_last, nulls_first] |
materialized.index.storage_params
materialized.index.storage_params attributes
| Name | Required | Value |
|---|---|---|
autosummarize | false | bool |
buffering | false |
|
deduplicate_items | false | bool |
fastupdate | false | bool |
fillfactor | false | int |
gin_pending_list_limit | false | int |
pages_per_range | false | int |
materialized.index.storage_params constraints
| Constraint | Value |
|---|---|
| Required | false |
| Require Name | false |
| Allow unknown attributes | true |
materialized.index constraints
| Constraint | Value |
|---|---|
| Required | false |
Require Name (e.g., materialized.index "name" ) | true |
| Mutually exclusive sets | [columns, on], [page_per_range, storage_params] |
| One of required sets | [columns, on] |
materialized constraints
| Constraint | Value |
|---|---|
| Required | false |
Require Name (e.g., materialized "name" ) | true |
Allow Qualifier (e.g., materialized "schema" "name" ) | true |
partition
The partition block describes a partition in the schema.
partition "cities_partition" {
of = table.cities
}
partition "cities_1000_to_100000" {
of = table.cities
range {
from = [1000]
to = [100000]
}
}
partition "orders_p1" {
of = table.orders
with {
modules = 4
remainder = 0
}
}
partition attributes
| Name | Required | Value |
|---|---|---|
comment | false | string |
name | false | string |
of | true | Parent table can be one of: |
schema | true | Object reference to |
partition blocks
partition.check
partition.check attributes
| Name | Required | Value |
|---|---|---|
expr | true | string |
partition.check constraints
| Constraint | Value |
|---|---|
| Required | false |
| Require Name | false |
| Repeatable | true |
partition.column
partition.column attributes
| Name | Required | Value |
|---|---|---|
default | false | Column default value can be one of:
|
null | false | bool |
type | true | Column type can be one of: |
partition.column constraints
| Constraint | Value |
|---|---|
| Required | false |
Require Name (e.g., partition.column "name" ) | true |
partition.foreign_key
partition.foreign_key attributes
| Name | Required | Value |
|---|---|---|
columns | true | Foreign key columns can be one of:
|
comment | false | string |
deferrable | false |
|
on_delete | false |
|
on_update | false |
|
ref_columns | true | Foreign key reference columns can be one of:
|
partition.foreign_key constraints
| Constraint | Value |
|---|---|
| Required | false |
Require Name (e.g., partition.foreign_key "name" ) | true |
partition.hash
partition.hash attributes
| Name | Required | Value |
|---|---|---|
modulus | true | int |
remainder | true | int |
partition.index
partition.index attributes
| Name and description | Required | Value |
|---|---|---|
The index on a partitioned table to which this index is attached. | false | Object reference to |
columns | false | Index columns can be one of:
|
comment | false | string |
include | false | Index included columns can be one of:
|
nulls_distinct | false | bool |
page_per_range | false | int |
type | false | Index key type can be one of:
|
unique | false | bool |
where | false | string |
partition.index blocks
partition.index.on
partition.index.on attributes
| Name | Required | Value |
|---|---|---|
column | false | Index columns can be one of:
|
desc | false | bool |
expr | false | string |
nulls_first | false | bool |
nulls_last | false | bool |
ops | false | Index operator class can be one of:
|
partition.index.on constraints
| Constraint | Value |
|---|---|
| Required | false |
| Require Name | false |
| Repeatable | true |
| Mutually exclusive sets | [column, expr], [nulls_last, nulls_first] |
partition.index.storage_params
partition.index.storage_params attributes
| Name | Required | Value |
|---|---|---|
autosummarize | false | bool |
buffering | false |
|
deduplicate_items | false | bool |
fastupdate | false | bool |
fillfactor | false | int |
gin_pending_list_limit | false | int |
pages_per_range | false | int |
partition.index.storage_params constraints
| Constraint | Value |
|---|---|
| Required | false |
| Require Name | false |
| Allow unknown attributes | true |
partition.index constraints
| Constraint | Value |
|---|---|
| Required | false |
Require Name (e.g., partition.index "name" ) | true |
| Mutually exclusive sets | [columns, on], [page_per_range, storage_params] |
| One of required sets | [columns, on] |
partition.list
partition.list attributes
| Name | Required | Value |
|---|---|---|
in | true | List of strings |
partition.partition
partition.partition attributes
| Name | Required | Value |
|---|---|---|
columns | false | Partition columns can be one of:
|
type | true |
|
partition.partition blocks
partition.partition.by
partition.partition.by attributes
| Name | Required | Value |
|---|---|---|
column | false | Partition columns can be one of:
|
expr | false | string |
partition.partition.by constraints
| Constraint | Value |
|---|---|
| Required | false |
| Require Name | false |
| Repeatable | true |
| Mutually exclusive sets | [column, expr] |
partition.range
partition.range attributes
| Name | Required | Value |
|---|---|---|
from | true | List of strings |
to | true | List of strings |
partition constraints
| Constraint | Value |
|---|---|
| Required | false |
| Require Name | false |
| Repeatable | true |
| Mutually exclusive sets | [hash, range, list] |
policy
The policy block describes a row-level security policy for a table.
policy "policy_name" {
on = table.users
for = UPDATE
to = [PUBLIC]
check = "(name = ( SELECT name FROM allowed_names))"
}
policy attributes
| Name | Required | Value |
|---|---|---|
as | false |
|
check | false | string |
comment | false | string |
for | false |
|
on | true | Object reference to |
to | false | List of strings or/and |
using | false | string |
policy constraints
| Constraint | Value |
|---|---|
| Required | false |
Require Name (e.g., policy "name" ) | true |
| 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 |
depends_on | false | List of object references |
lang | true | Procedure language can be one of:
|
schema | true | Object reference to |
security | false |
|
procedure 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:
|
type | true | Procedure argument type can be one of: |
procedure.arg constraints
| Constraint | Value |
|---|---|
| Required | false |
| Require Name | false |
| Repeatable | true |
procedure.config_params
The config_params block describes the configuration parameters to be set when the procedure is entered.
config_params {
search_path = "public"
work_mem = "64MB"
client_min_messages = "warning"
// Other custom configuration parameters.
}
procedure.config_params attributes
| Name | Required | Value |
|---|---|---|
schema | false | string |
search_path | false | string |
statement_timeout | false | string |
work_mem | false | string |
procedure.config_params constraints
| Constraint | Value |
|---|---|
| Required | false |
| Require Name | false |
| Allow unknown attributes | true |
procedure constraints
| Constraint | Value |
|---|---|
| Required | false |
Require Name (e.g., procedure "name" ) | true |
Allow Qualifier (e.g., procedure "schema" "name" ) | true |
| Repeatable | true |
range
The range block describes a range type in the schema.
range "time_range" {
schema = schema.public
subtype = time
subtype_diff = function.time_diff
multirange_name = "multirange_name"
}
range attributes
| Name | Required | Value |
|---|---|---|
comment | false | string |
multirange_name | false | string |
name | false | string |
schema | true | Object reference to |
subtype | true | Range subtype can be one of: |
subtype_diff | false | Range subtype difference function can be one of:
|
range constraints
| Constraint | Value |
|---|---|
| Required | false |
Require Name (e.g., range "name" ) | true |
Allow Qualifier (e.g., range "schema" "name" ) | true |
schema
The schema block describes a database schema.
schema "public" {
...
}
schema attributes
| Name | Required | Value |
|---|---|---|
comment | false | string |
name | false | string |
schema constraints
| Constraint | Value |
|---|---|
| Required | false |
Require Name (e.g., schema "name" ) | true |
sequence
The sequence block describes a sequence in a database schema.
sequence "name" {
schema = schema.public
type = int
increment = 3
min_value = 9
}
sequence attributes
| Name | Required | Value |
|---|---|---|
cache | false | int |
comment | false | string |
cycle | false | bool |
increment | false | int |
max_value | false | int |
min_value | false | int |
owner | false | Object reference to |
schema | true | Object reference to |
start | false | int |
type | false | Schema type |
sequence constraints
| Constraint | Value |
|---|---|
| Required | false |
Require Name (e.g., sequence "name" ) | true |
Allow Qualifier (e.g., sequence "schema" "name" ) | true |
server
The server block describes a foreign server in the database.
server "foreign_server_name" {
fdw = extension.postgres_fdw
options = {
host = "127.0.0.1"
port = "5432"
dbname = "postgres"
}
}
server "foreign_server_name" {
fdw = "foreign_data_wrapper_name"
options = {
host = "127.0.0.1"
port = "5432"
dbname = "postgres"
}
}
server attributes
| Name and description | Required | Value |
|---|---|---|
comment | false | string |
The | false | List of object reference to |
fdw | true | Foreign data wrapper can be one of:
|
options | false | map |
type | false | string |
version | false | string |
server constraints
| Constraint | Value |
|---|---|
| Required | false |
Require Name (e.g., server "name" ) | true |
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 |
|---|---|---|
access_method | false | Table access method can be one of:
|
comment | false | string |
depends_on | false | List of object references |
schema | true | Object reference to |
unlogged | false | bool |
table blocks
table.check
table.check attributes
| Name | Required | Value |
|---|---|---|
comment | false | string |
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 |
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.identity
table.column.identity attributes
| Name | Required | Value |
|---|---|---|
generated | false |
|
increment | false | int |
start | false | int |
table.column constraints
| Constraint | Value |
|---|---|
| Required | false |
Require Name (e.g., table.column "name" ) | true |
| Mutually exclusive sets | [as (attribute), as (block)] |
table.exclude
table.exclude attributes
| Name | Required | Value |
|---|---|---|
comment | false | string |
deferrable | false |
|
include | false | Index included columns can be one of:
|
nulls_distinct | false | bool |
page_per_range | false | int |
type | false | Index key type can be one of:
|
where | false | string |
table.exclude blocks
table.exclude.on
table.exclude.on attributes
| Name | Required | Value |
|---|---|---|
column | false | Index columns can be one of:
|
desc | false | bool |
expr | false | string |
op | false | Exclude element operator can be one of:
|
table.exclude.on constraints
| Constraint | Value |
|---|---|
| Required | true |
| Require Name | false |
| Repeatable | true |
| Mutually exclusive sets | [column, expr] |
table.exclude constraints
| Constraint | Value |
|---|---|
| Required | false |
Require Name (e.g., table.exclude "name" ) | true |
table.foreign_key
table.foreign_key attributes
| Name | Required | Value |
|---|---|---|
columns | true | Foreign key columns can be one of:
|
comment | false | string |
deferrable | false |
|
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 |
include | false | Index included columns can be one of:
|
nulls_distinct | false | bool |
page_per_range | false | int |
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 |
nulls_first | false | bool |
nulls_last | false | bool |
ops | false | Index operator class can be one of:
|
table.index.on constraints
| Constraint | Value |
|---|---|
| Required | false |
| Require Name | false |
| Repeatable | true |
| Mutually exclusive sets | [column, expr], [nulls_last, nulls_first] |
table.index.storage_params
table.index.storage_params attributes
| Name | Required | Value |
|---|---|---|
autosummarize | false | bool |
buffering | false |
|
deduplicate_items | false | bool |
fastupdate | false | bool |
fillfactor | false | int |
gin_pending_list_limit | false | int |
pages_per_range | false | int |
table.index.storage_params constraints
| Constraint | Value |
|---|---|
| Required | false |
| Require Name | false |
| Allow unknown attributes | true |
table.index constraints
| Constraint | Value |
|---|---|
| Required | false |
Require Name (e.g., table.index "name" ) | true |
| Mutually exclusive sets | [columns, on], [page_per_range, storage_params] |
| One of required sets | [columns, on] |
table.partition
table.partition attributes
| Name | Required | Value |
|---|---|---|
columns | false | Partition columns can be one of:
|
type | true |
|
table.partition blocks
table.partition.by
table.partition.by attributes
| Name | Required | Value |
|---|---|---|
column | false | Partition columns can be one of:
|
expr | false | string |
table.partition.by constraints
| Constraint | Value |
|---|---|
| Required | false |
| Require Name | false |
| Repeatable | true |
| Mutually exclusive sets | [column, expr] |
table.primary_key
table.primary_key attributes
| Name | Required | Value |
|---|---|---|
columns | true | Primary key columns can be one of:
|
comment | false | string |
deferrable | false |
|
include | false | Primary key included columns can be one of:
|
page_per_range | false | int |
type | false | Index key type can be one of:
|
table.primary_key blocks
table.primary_key.storage_params
table.primary_key.storage_params attributes
| Name | Required | Value |
|---|---|---|
autosummarize | false | bool |
buffering | false |
|
deduplicate_items | false | bool |
fastupdate | false | bool |
fillfactor | false | int |
gin_pending_list_limit | false | int |
pages_per_range | false | int |
table.primary_key.storage_params constraints
| Constraint | Value |
|---|---|
| Required | false |
| Require Name | false |
| Allow unknown attributes | true |
table.primary_key constraints
| Constraint | Value |
|---|---|
| Required | false |
| Require Name | false |
| Mutually exclusive sets | [page_per_range, storage_params] |
table.row_security
table.row_security attributes
| Name | Required | Value |
|---|---|---|
enabled | false | bool |
enforced | false | bool |
table.unique
table.unique attributes
| Name | Required | Value |
|---|---|---|
columns | true | Index columns can be one of:
|
comment | false | string |
deferrable | false |
|
include | false | Index included columns can be one of:
|
nulls_distinct | false | bool |
table.unique blocks
table.unique.storage_params
table.unique.storage_params attributes
| Name | Required | Value |
|---|---|---|
autosummarize | false | bool |
buffering | false |
|
deduplicate_items | false | bool |
fastupdate | false | bool |
fillfactor | false | int |
gin_pending_list_limit | false | int |
pages_per_range | false | int |
table.unique.storage_params constraints
| Constraint | Value |
|---|---|
| Required | false |
| Require Name | false |
| Allow unknown attributes | true |
table.unique constraints
| Constraint | Value |
|---|---|
| Required | false |
Require Name (e.g., table.unique "name" ) | true |
| Mutually exclusive sets | [page_per_range, storage_params] |
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 | false | string |
comment | false | string |
constraint | false | bool |
deferrable | false |
|
for | false |
|
foreach | false |
|
from | false | Object reference to |
on | true | Trigger on can be one of: |
when | false | string |
trigger blocks
trigger.after
trigger.after attributes
| Name | Required | Value |
|---|---|---|
delete | false | bool |
insert | false | bool |
truncate | false | bool |
update | false | bool |
update_of | false | Trigger update_of columns can be one of:
|
trigger.after constraints
| Constraint | Value |
|---|---|
| Required | false |
| Require Name | false |
| Mutually exclusive sets | [update, update_of] |
| One of required sets | [insert, delete, truncate, update, update_of] |
trigger.before
trigger.before attributes
| Name | Required | Value |
|---|---|---|
delete | false | bool |
insert | false | bool |
truncate | false | bool |
update | false | bool |
update_of | false | Trigger update_of columns can be one of:
|
trigger.before constraints
| Constraint | Value |
|---|---|
| Required | false |
| Require Name | false |
| Mutually exclusive sets | [update, update_of] |
| One of required sets | [insert, delete, truncate, update, update_of] |
trigger.execute
trigger.execute attributes
| Name | Required | Value |
|---|---|---|
args | false | List of strings |
function | false | Object reference to |
procedure | false | Object reference to |
trigger.execute constraints
| Constraint | Value |
|---|---|
| Required | false |
| Require Name | false |
| Mutually exclusive sets | [function, procedure] |
| One of required sets | [function, procedure] |
trigger.instead_of
trigger.instead_of attributes
| Name | Required | Value |
|---|---|---|
delete | false | bool |
insert | false | bool |
truncate | false | bool |
update | false | bool |
update_of | false | Trigger update_of columns can be one of:
|
trigger.instead_of constraints
| Constraint | Value |
|---|---|
| Required | false |
| Require Name | false |
| Mutually exclusive sets | [update, update_of] |
| One of required sets | [insert, delete, truncate, update, update_of] |
trigger.referencing
trigger.referencing attributes
| Name | Required | Value |
|---|---|---|
new_table | false | string |
old_table | false | string |
trigger.referencing constraints
| Constraint | Value |
|---|---|
| Required | false |
| Require Name | false |
| Repeatable | true |
trigger constraints
| Constraint | Value |
|---|---|
| Required | false |
Require Name (e.g., trigger "name" ) | true |
| Repeatable | true |
| Mutually exclusive sets | [foreach, for], [before, after, instead_of], [as, execute] |
| One of required sets | [before, after, instead_of], [as, execute] |
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 |
view blocks
view.column
view.column attributes
| Name | Required | Value |
|---|---|---|
comment | false | string |
null | false | bool |
type | true | Column type can be one of: |
view.column constraints
| Constraint | Value |
|---|---|
| Required | false |
Require Name (e.g., view.column "name" ) | true |
view.security
view.security attributes
| Name | Required | Value |
|---|---|---|
barrier | false | bool |
invoker | false | bool |
view.security constraints
| Constraint | Value |
|---|---|
| Required | false |
| Require Name | false |
| One of required sets | [invoker, barrier] |
view constraints
| Constraint | Value |
|---|---|
| Required | false |
Require Name (e.g., view "name" ) | true |
Allow Qualifier (e.g., view "schema" "name" ) | true |