Spanner Schema
schema
The schema
block describes a database schema.
schema "public" {
...
}
schema
constraints
Constraint | Value |
---|---|
Required | false |
Require Name (e.g., schema "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 |
---|---|---|
depends_on | false | List of object references |
row_deletion_policy | false | Raw expression defined with |
schema | true | Object reference to |
table
blocks
table.check
table.check
attributes
Name | Required | Value |
---|---|---|
expr | true | string |
table.check
constraints
Constraint | Value |
---|---|
Required | false |
Require Name (e.g., table.check "name" ) | true |
Repeatable | true |
table.column
table.column
attributes
Name | Required | Value |
---|---|---|
default | false | Column default expression 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.options
table.column.options
attributes
Name | Required | Value |
---|---|---|
allow_commit_timestamp | false | bool |
table.column
constraints
Constraint | Value |
---|---|
Required | false |
Require Name (e.g., table.column "name" ) | true |
table.foreign_key
table.foreign_key
attributes
Name | Required | Value |
---|---|---|
columns | true | Foreign key columns can be one of:
|
on_delete | 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:
|
null_filtered | false | bool |
unique | false | bool |
table.index
blocks
table.index.on
table.index.on
attributes
Name | Required | Value |
---|---|---|
column | false | Index columns can be one of:
|
desc | false | bool |
table.index.on
constraints
Constraint | Value |
---|---|
Required | false |
Require Name | false |
Repeatable | true |
table.index
constraints
Constraint | Value |
---|---|
Required | false |
Require Name (e.g., table.index "name" ) | true |
Mutually exclusive sets | [columns, on] |
One of required sets | [columns, on] |
table.interleave
The interleave
block defines a Spanner interleaved table relationship.
table "name" {
schema = schema.public
interleave {
parent = table.parent_table
type = IN_PARENT
on_delete = CASCADE
}
}
table.interleave
attributes
Name | Required | Value |
---|---|---|
on_delete | false |
|
parent | true | Object reference to |
type | false |
|
table.primary_key
table.primary_key
attributes
Name | Required | Value |
---|---|---|
columns | false | Index columns can be one of:
|
table.primary_key
blocks
table.primary_key.on
table.primary_key.on
attributes
Name | Required | Value |
---|---|---|
column | false | Index columns can be one of:
|
desc | false | bool |
table.primary_key.on
constraints
Constraint | Value |
---|---|
Required | false |
Require Name | false |
Repeatable | true |
table.primary_key
constraints
Constraint | Value |
---|---|
Required | false |
Require Name | false |
Mutually exclusive sets | [columns, on] |
One of required sets | [columns, on] |
table
constraints
Constraint | Value |
---|---|
Required | false |
Require Name (e.g., table "name" ) | true |
Allow Qualifier (e.g., table "schema" "name" ) | true |
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 |
schema | true | Object reference to |
security | true |
|
view
constraints
Constraint | Value |
---|---|
Required | false |
Require Name (e.g., view "name" ) | true |
Allow Qualifier (e.g., view "schema" "name" ) | true |