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 |
collation
The collation block describes a collation in the schema.
collation "french" {
schema = schema.public
locale = "fr-x-icu"
provider = icu
}
collation "german" {
schema = schema.public
from = "german_phonebook"
}
collation attributes
| Name | Required | Value |
|---|---|---|
comment | false | string |
deterministic | false | bool |
lc_collate | false | string |
lc_ctype | false | string |
locale | false | string |
name | false | string |
provider | false | Collation provider can be one of:
|
rules | false | string |
schema | true | Object reference to |
version | false | string |
collation constraints
| Constraint | Value |
|---|---|
| Required | false |
Require Name (e.g., collation "name" ) | true |
Allow Qualifier (e.g., collation "schema" "name" ) | 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 | Field collation can be one of:
|
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 | Column collation can be one of:
|
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 |