The information schema is a built-in schema that's common to every
PostgreSQL database. You can run SQL queries against tables in the information_schema
to fetch schema metadata for a database.
For example, the following query fetches the names of all user-defined tables in a database:
SELECT
table_schema
,
table_name
FROM
information_schema
.
tables
WHERE
table_schema
NOT
IN
(
'pg_catalog'
,
'information_schema'
,
'SPANNER_SYS'
)
AND
table_type
=
'BASE TABLE'
Usage
-
information_schema
tables are available only through SQL interfaces, for example:- The
executeQuery
API - The
gcloud spanner databases execute-sql
command - The Querypage of a database in the Google Cloud console.
Other single read methods don't support
information_schema
. - The
- Queries against the
information_schema
can use strong, bounded staleness, or exact staleness timestamp bounds . - If you are using a GoogleSQL-dialect database, see Information schema for GoogleSQL-dialect databases .
Differences from information_schema
for PostgreSQL
The tables in the information_schema
for PostgreSQL-dialect databases include columns from
the tables in the information_schema
for open source PostgreSQL and in
some cases also include columns from Spanner. In these tables, the
open source PostgreSQL columns come first and in the same order as they do
for a open source PostgreSQL database, and any distinct columns for
Spanner are appended afterwards. Queries written for the
open source PostgreSQL version of information_schema
should work without
modification when using PostgreSQL-dialect databases in Google Cloud CLI.
Other notable differences in the information_schema
for PostgreSQL-dialect databases are:
- Some of the table columns for open source PostgreSQL are available, but not populated in PostgreSQL-dialect databases.
- PostgreSQL-dialect databases use
public
for the default schema name. - Automatically generated constraint names use a different format than open source PostgreSQL databases.
- Tables related to open source PostgreSQL features that are not supported in PostgreSQL-dialect databases are not available.
- Some tables that are available with Spanner but not
open source PostgreSQL, such as
database_options
,index_columns
,indexes
, andspanner_statistics
are available.
Row filtering in information_schema
tables and views
Principals that have database-level IAM permissions and
principals who have been granted access to the spanner_info_reader
system
role
(or to members of that role) can see all
rows in all information_schema
tables and views. For other principals,
Spanner filters rows based on the current database role. The
table and view descriptions in the following sections indicate how
Spanner filters rows for each table and view.
Tables in information_schema
for PostgreSQL-dialect databases
The tables and views in the information_schema
are compatible with the tables
and views in the information_schema
of open source PostgreSQL.
The following sections describe the tables and views in the information_schema
for PostgreSQL-dialect databases.
applicable_roles
This row-filtered view lists all role memberships that are explicitly granted to
all database roles. Principals that have database-level IAM
permissions and principals who have been granted access to the spanner_info_reader
system role or to members of that role can see all rows in
this view. All other principals can see only the role memberships that are
granted to the current database role or to a role of which the current database
role is a member.
Because all database roles are members of the public role , the results omit records for implicit membership in the public role.
Column name | Type | Description |
---|---|---|
grantee
|
character varying
|
The name of the database role to which membership is granted. |
role_name
|
character varying
|
The name of the parent database role in which this membership is granted. |
is_grantable
|
character varying
|
Not used. Always NO
. |
change_stream_columns
This row-filtered view contains information about table columns and the change streams that watch them. Each row describes one change stream and one column. If a change stream tracks an entire table, then the columns in that table don't show in this view.
Principals that have database-level IAM permissions and
principals who have been granted access to the spanner_info_reader
system role
or to members of that role can see all rows in this view. All other principals
can see only rows for change streams on which the SELECT
privilege is granted
to the current database role, to roles of which the current database role is a
member, or to public
.
Column name | Type | Description |
---|---|---|
change_stream_catalog
|
character varying
|
The database name. |
change_stream_schema
|
character varying
|
The name of the change stream's schema. For PostgreSQL-dialect databases, the default
is public
. |
change_stream_name
|
character varying
|
The name of the change stream. |
table_catalog
|
character varying
|
The database name. |
table_schema
|
character varying
|
The name of the table's schema. For PostgreSQL-dialect databases, the default
is public
. |
table_name
|
character varying
|
The name of the table that this row refers to. |
column_name
|
character varying
|
The name of the column that this row refers to. |
change_stream_options
This row-filtered view contains the configuration options for change streams.
Principals that have database-level IAM permissions and principals who
have been granted access to the spanner_info_reader
system role or to members
of that role can see all rows in this view. All other principals can see only
options for change streams on which the SELECT
privilege is granted to the
current database role, to roles of which the current database role is a member,
or to public
.
Column name | Type | Description |
---|---|---|
change_stream_catalog
|
character varying
|
The database name. |
change_stream_schema
|
character varying
|
The name of the change stream's schema. For PostgreSQL-dialect databases, the default
is public
. |
change_stream_name
|
character varying
|
The name of the change stream. |
option_name
|
character varying
|
The name of the change stream option. |
option_type
|
character varying
|
The data type of the change stream option. |
option_value
|
character varying
|
The value of the change stream option. |
change_stream_privileges
This row-filtered view lists all fine-grained access control privileges granted on all change
streams to any database role, including public
. Principals that have
database-level IAM permissions and principals who have been
granted access to the spanner_info_reader
system role or to members of that
role can see all rows in this view. All other principals can see only privileges
granted on change streams to the current database role, to roles of which the
current database role is a member, or to public
.
Column name | Type | Description |
---|---|---|
grantor
|
character varying
|
Not used. Always NULL
. |
grantee
|
character varying
|
The name of the database role to which this privilege is granted. |
change_stream_catalog
|
character varying
|
The database name. |
change_stream_schema
|
character varying
|
The name of the schema that contains the change stream.
The default is public
for PostgreSQL-dialect databases. |
change_stream_name
|
character varying
|
The name of the change stream. |
privilege_type
|
character varying
|
The type of the privilege ( SELECT
only). |
is_grantable
|
character varying
|
Not used. Always NO
. |
change_stream_tables
This row-filtered view contains information about tables and the change streams
that watch them. Each row describes one table and one change stream. Principals
that have database-level IAM permissions and principals who have been
granted access to the spanner_info_reader
system role or to members of that
role can see all rows in this view. All other principals can see only rows for
change streams on which the SELECT
privilege is granted to the current
database role, to roles of which the current database role is a member, or to public
.
The data in change_stream_tables
does not include the implicit relationships
between tables and change streams that track the entire database.
Column name | Type | Description |
---|---|---|
change_stream_catalog
|
character varying
|
The database name. |
change_stream_schema
|
character varying
|
The name of the change stream's schema. For PostgreSQL-dialect databases, the default
is public
. |
change_stream_name
|
character varying
|
The name of the change stream that this row refers to. |
table_catalog
|
character varying
|
The database name. |
table_schema
|
character varying
|
The name of the table's schema. For PostgreSQL-dialect databases, the default
is public
. |
table_name
|
character varying
|
The name of the table that this row refers to. |
all_columns
|
character varying
|
YES
if this row's change stream tracks the entirety of the
table this row refers to. Otherwise, NO
. In accordance with the
SQL standard, the string is either YES
or NO
,
rather than a Boolean value. |
change_streams
This row-filtered view lists all of a database's change streams, and notes which
ones track the entire database versus specific tables or columns. Principals
that have database-level IAM permissions and principals who have been
granted access to the spanner_info_reader
system role or to members of that
role can see all rows in this view. All other principals can see only change
streams on which the SELECT
fine-grained access control privilege is granted to the current
database role, to roles of which the current database role is a member, or to public
.
Column name | Type | Description |
---|---|---|
change_stream_catalog
|
character varying
|
The database name. |
change_stream_schema
|
character varying
|
The name of this change stream's schema. For PostgreSQL-dialect databases, the default
is public
. |
change_stream_name
|
character varying
|
The name of the change stream. |
all
|
character varying
|
YES
if this change stream tracks the entire database. NO
if this change stream tracks specific tables or columns.
In accordance with the SQL standard, the string is either YES
or NO
, rather than a Boolean value. |
check_constraints
The check_constraints
view contains one row for each
check constraint defined by either the CHECK
or the NOT NULL
keyword.
constraint_catalog
character varying
constraint_schema
character varying
public
for PostgreSQL-dialect databases.constraint_name
character varying
check_clause
character varying
spanner_state
character varying
-
VALIDATING
: The PostgreSQL-dialect database is validating the existing data for anALTER CONSTRAINT
orADD CONSTRAINT
command. -
COMMITTED
: There is no active schema change for this constraint.
column_column_usage
This view lists all the generated columns that depend on another base column in the same table.
Column name | Type | Description |
---|---|---|
table_catalog
|
character varying
|
The database name. |
table_schema
|
character varying
|
The name of the schema that contains the table. The name is public
for
the default schema and non-empty for other schemas (for example, the information_schema
itself). This column is never null. |
table_name
|
character varying
|
The name of the table that contains the generated columns. |
column_name
|
character varying
|
The name of the base column that the generated column depends on. |
dependent_column
|
character varying
|
The name of the generated column. |
column_options
This view lists all the options defined for the referenced table columns of a foreign key constraint. The view contains only those columns in the reference table that the current user has access to (by way of being the owner or granted privileges).
Column name | Type | Description |
---|---|---|
table_catalog
|
character varying
|
The database name. |
table_schema
|
character varying
|
The name of the schema that contains the foreign table. The name is public
for the default schema and non-empty for other schemas (for
example, the information_schema
itself). This column is never
null. |
table_name
|
character varying
|
The name of the foreign table. |
column_name
|
character varying
|
The name of the column. |
option_name
|
character varying
|
A SQL identifier that uniquely identifies the option. This identifier
is the key of the OPTIONS
clause in DDL. |
option_value
|
character varying
|
A SQL literal describing the value of this option. The value of this column is parsable as part of a query. |
option_type
|
character varying
|
A data type name that is the type of this option value. |
column_privileges
This row-filtered view lists all fine-grained access control privileges granted on all columns
to any database role, including public
. Principals that have IAM
database-level permissions and principals who have been granted access to the spanner_info_reader
system role or to members of that role can see all rows in
this view. All other principals can see only privileges granted on columns to
the current database role, to roles of which the current database role is a
member, or to public
.
The view includes the SELECT
, INSERT
, and UPDATE
privileges that the
column inherits from the table or view that contains the column.
Column name | Type | Description |
---|---|---|
grantor
|
character varying
|
Not used. Always NULL
. |
grantee
|
character varying
|
The name of the database role to which this privilege is granted. |
table_catalog
|
character varying
|
The database name. |
table_schema
|
character varying
|
The name of the schema that contains the table or view. The
default is public
for PostgreSQL-dialect databases. |
table_name
|
character varying
|
The name of the table or view that contains the column. |
column_name
|
character varying
|
The name of the column. |
privilege_type
|
character varying
|
The type of the privilege ( SELECT
, INSERT
, or UPDATE
). |
is_grantable
|
character varying
|
Not used. Always NO
. |
columns
This row-filtered view provides information about all table columns and view
columns in the database. Principals that have database-level IAM
permissions and principals who have been granted access to the spanner_info_reader
system role or to members of that role can see all rows in
this view. All other principals can see only columns that have any fine-grained access control
privileges granted on them (or the SELECT
, INSERT
or UPDATE
privileges
granted on their containing tables) to the current database role, to roles of
which the current database role is a member, or to public
.
table_catalog
character varying
table_schema
character varying
public
for the default schema and non-empty for other schemas (for
example, the information_schema
itself). This column is never
null.table_name
character varying
column_name
character varying
ordinal_position
BIGINT
column_default
character varying
'9'::bigint
.is_nullable
character varying
YES
or NO
, rather than a Boolean value.data_type
character varying
- For built-in types, the name of the data type.
- For arrays, the value ARRAY.
character_maximum_length
BIGINT
NULL
. If the data
type of the column is not a character or bit string, then the value is NULL
.character_octet_length
BIGINT
NULL
.numeric_precision
BIGINT
double precision
, the value is 53. For bigint
, the value is 64.
For all other data types, the value is NULL
.numeric_precision_radix
BIGINT
- 2 for
double precision
float8
, andbigint
- 10 for
numeric
NULL
.numeric_scale
BIGINT
bigint
, the
value is 0.
For all other data types, the value is NULL
.datetime_precision
BIGINT
NULL
.interval_type
character varying
NULL
.interval_precision
BIGINT
NULL
.character_set_catalog
character varying
NULL
.character_set_schema
character varying
NULL
.character_set_name
character varying
NULL
.collation_catalog
character varying
NULL
.collation_schema
character varying
NULL
.collation_name
character varying
NULL
.domain_catalog
character varying
NULL
.domain_schema
character varying
NULL
.domain_name
character varying
NULL
.udt_catalog
character varying
NULL
.udt_schema
character varying
NULL
.udt_name
character varying
NULL
.scope_catalog
character varying
NULL
.scope_schema
character varying
NULL
.scope_name
character varying
NULL
.maximum_cardinality
BIGINT
NULL
.dtd_identifier
character varying
NULL
.is_self_referencing
character varying
NULL
.is_identity
character varying
NULL
.identity_generation
character varying
NULL
.identity_start
character varying
NULL
.identity_increment
character varying
NULL
.identity_maximum
character varying
NULL
.identity_minimum
character varying
NULL
.identity_cycle
character varying
NULL
.is_generated
character varying
ALWAYS
for a generated column or NEVER
for a non-generated column.generation_expression
character varying
NULL
if the column is not a generated column.is_updatable
character varying
NULL
.spanner_type
character varying
is_stored
character varying
YES
or NO
for generated
columns, and NULL
for non-generated columns.spanner_state
character varying
-
NO_WRITE
: No read or write is allowed to the columns. A stored generated column in this state does not cause any client effect. -
WRITE_ONLY
: The column is being backfilled. No read is allowed. -
COMMITTED
: The column is fully usable. -
NULL
: Used for columns in system schemas.
constraint_column_usage
This view contains one row about each column used by a constraint.
- For
PRIMARY KEY
andCHECK
constraints defined by theNOT NULL
keyword, the view contains those columns. - For
CHECK
constraints created with theCHECK
keyword, the view includes the columns used by the check constraint expression. - For foreign key constraints, the view contains the columns of the referenced table.
- For
UNIQUE
constraints, the view contains the columns fromKEY_COLUMN_USAGE
.
Column name | Type | Description |
---|---|---|
table_catalog
|
character varying
|
The database name. |
table_schema
|
character varying
|
The name of the schema that contains the table that contains the column that is used by the constraint. |
table_name
|
character varying
|
The name of the table that contains the column that is used by the constraint. |
column_name
|
character varying
|
The name of the column that is used by the constraint. |
constraint_catalog
|
character varying
|
The database name. |
constraint_schema
|
character varying
|
The name of the constraint's schema. |
constraint_name
|
character varying
|
The name of the constraint. |
constraint_table_usage
This view contains one row for each table used by a constraint. For FOREIGN
KEY
constraints, the table information is for the tables in the REFERENCES
clause. For a unique or primary key constraint, this view identifies the
table the constraint belongs to. Check constraints and not-null constraints are
not included in this view.
Column name | Type | Description |
---|---|---|
table_catalog
|
character varying
|
The database name. |
table_schema
|
character varying
|
The name of the constrained table's schema. |
table_name
|
character varying
|
The name of the table that is used by some constraint. |
constraint_catalog
|
character varying
|
The database name. |
constraint_schema
|
character varying
|
The name of the schema that contains the constraint. |
constraint_name
|
character varying
|
The name of the constraint. |
database_options
This table lists the options that are set on the database.
Column name | Type | Description |
---|---|---|
catalog_name
|
character varying
|
The database name. |
schema_name
|
character varying
|
The name of the schema. The default value is public
for
PostgreSQL-dialect databases. |
option_name
|
character varying
|
The name of the database option. This is the value of key
in the OPTIONS
clause in DDL. |
option_type
|
character varying
|
The data type of the database option. |
option_value
|
character varying
|
The value of the database option. |
enabled_roles
This row-filtered view lists the defined database roles. Principals that have
database-level IAM permissions and principals who have been
granted access to the spanner_info_reader
system role or to members of
that role can see all database roles. All other principals can see only
database roles to which they have been granted access either directly or through
inheritance. All system roles excluding public
also appear in this view.
Column name | Type | Description |
---|---|---|
role_name
|
character varying
|
The name of the role. |
spanner_is_system
|
character varying
|
YES
if the role is a system role. Otherwise, NO
. |
index_columns
This view lists the columns in an index.
Column name | Type | Description |
---|---|---|
table_catalog
|
character varying
|
The database name. |
table_schema
|
character varying
|
The name of the schema that contains the index. The default value is public
. |
table_name
|
character varying
|
The name of the table associated with the index. |
index_name
|
character varying
|
The name of the index. Tables that have a PRIMARY KEY
specification have a pseudo-index entry generated with the name PRIMARY_KEY
. |
index_type
|
character varying
|
The type of index. Possible values are PRIMARY_KEY
, LOCAL
, or GLOBAL
. |
column_name
|
character varying
|
The name of the column. |
ordinal_position
|
BIGINT
|
The ordinal position of the column in the index (or primary
key), starting with a value of 1. This value is NULL
for non-key
columns (for example, columns specified in the INCLUDE
clause
of an index). |
column_ordering
|
character varying
|
The sort order of the column. The value is ASC
or DESC
for key columns, and NULL
for non-key
columns (for example, columns specified in the STORING
clause of an index). |
is_nullable
|
character varying
|
A string that indicates whether the column is nullable. In accordance
with the SQL standard, the string is either YES
or NO
, rather than a Boolean value. |
spanner_type
|
character varying
|
A string holding the DDL-compatible type of the column. |
indexes
This view lists the indexes in a schema.
table_catalog
character varying
table_schema
character varying
public
.table_name
character varying
index_name
character varying
PRIMARY KEY
clause have a pseudo-index entry generated with the name PRIMARY_KEY
,
which allows the fields of the primary key to be identified.index_type
character varying
PRIMARY_KEY
, LOCAL
, or GLOBAL
.parent_table_name
character varying
is_unique
character varying
YES
or NO
, rather
than a Boolean value.is_null_filtered
character varying
NULL
values. In
accordance with the SQL standard, the string is either YES
or NO
, rather than a Boolean value.index_state
character varying
-
NULL
: the index type isPRIMARY_KEY
-
PREPARE
: creating empty tables for a new index -
WRITE_ONLY
: backfilling data for a new index -
WRITE_ONLY_CLEANUP
: cleaning up a new index -
WRITE_ONLY_VALIDATE_UNIQUE
: checking uniqueness of data in a new index -
READ_WRITE
: normal index operation
spanner_is_managed
character varying
YES
or NO
, rather than a
Boolean value, in accordance with the SQL standard. information_schema_catalog_name
This table contains one row and one column containing the database name.
Column name | Type | Description |
---|---|---|
catalog_name
|
character varying
|
The database name. |
key_column_usage
This view identifies all columns in the current database that are referenced by
a unique, primary key, or foreign key constraint. For information about CHECK
constraint columns, see the check_constraints
view.
Column name | Type | Description |
---|---|---|
constraint_catalog
|
character varying
|
The database name. |
constraint_schema
|
character varying
|
The name of the constraint's schema. The default value is public
. |
constraint_name
|
character varying
|
The name of the constraint. |
table_catalog
|
character varying
|
The database name. |
table_schema
|
character varying
|
The name of the schema that contains the table that contains the
constrained column. The default value is public
. |
table_name
|
character varying
|
The name of the table that contains the column that is restricted by this constraint. |
column_name
|
character varying
|
The name of the column that is constrained. |
ordinal_position
|
BIGINT
|
The ordinal position of the column within the constraint's key, starting
with a value of 1
. |
position_in_unique_constraint
|
BIGINT
|
For FOREIGN KEY
s, the ordinal position of the column within
the unique constraint, starting with a value of 1
. This
column has a NULL
value for other constraint types. |
parameters
This row-filtered view defines the arguments for each change stream read function. Each row describes one argument for one change stream read function.
Principals that have database-level IAM permissions and principals who
have been granted access to the spanner_info_reader
system role or to members
of that role can see all rows in this view. All other principals can see only
parameters for change stream read functions on which the EXECUTE
fine-grained access control
privilege is granted to the current database role, to roles of which the current
database role is a member, or to public
.
specific_catalog
character varying
specific_schema
character varying
public
.specific_name
character varying
ordinal_position
bigint
parameter_mode
character varying
NULL
.is_result
character varying
NULL
.as_locator
character varying
NULL
.parameter_name
character varying
data_type
character varying
- For built-in types, the name of the data type.
- For arrays, the value
ARRAY
.
character_maximum_length
bigint
NULL
.character_octet_length
bigint
NULL
.character_set_catalog
character varying
NULL
.character_set_schema
character varying
NULL
.character_set_name
character varying
NULL
.collation_catalog
character varying
NULL
.collation_schema
character varying
NULL
.collation_name
character varying
NULL
.numeric_precision
bigint
NULL
.numeric_precision_radix
bigint
NULL
.numeric_scale
bigint
NULL
.datetime_precision
bigint
NULL
.interval_type
character varying
NULL
.interval_precision
bigint
NULL
.udt_catalog
character varying
NULL
.udt_schema
character varying
NULL
.udt_name
character varying
NULL
.scope_catalog
character varying
NULL
.scope_schema
character varying
NULL
.scope_name
character varying
NULL
.maximum_cardinality
bigint
NULL
.dtd_identifier
character varying
NULL
.parameter_default
character varying
NULL
. placements
This table lists the placements in the database.
Column name | Type | Description |
---|---|---|
placement_name
|
character varying
|
The name of the placement. |
is_default
|
character varying
|
A string that indicates whether the column is nullable. In
accordance with the SQL standard, the string is either YES
or NO
, rather than a Boolean value. |
placement-options
For each placement, this table lists the options that are set on the placement
in the OPTIONS
clause of the CREATE PLACEMENT
statement.
placement_name
character varying
option_name
character varying
option_name
include: -
instance_partition
-
default_leader
option_type
character varying
option_value
character varying
instance_partition
,
this is the name of the instance partition. For default_leader
,
it's the name of the default leader region. locality-group-options
For each locality group, this table lists the name and options that are set on
the locality group in the OPTIONS
clause of the CREATE LOCALITY GROUP
statement.
locality_group_name
character varying
option_name
character varying
-
storage
: defines the storage type for the locality group. -
ssd_to_hdd_spill_timespan
: defines how long data is stored in SSD storage before it moves to HDD storage.
option_value
character varying
storage
,
this is either ssd
or hdd
. For ssd_to_hdd_spill_timespan
, this is the amount of time that
data must be stored in SSD before it's moved to HDD storage. For example, 10d
is 10 days. The minimum amount of time you can set is one
hour. referential_constraints
This view contains one row about each FOREIGN KEY
constraint. You can see only
those constraints for which you have write access to the referencing table. This
view also identifies the PRIMARY KEY
and UNIQUE
constraints on the
referenced tables that the foreign keys use for constraint enforcement and
referential actions.
constraint_catalog
character varying
constraint_schema
character varying
public
.constraint_name
character varying
unique_constraint_catalog
character varying
unique_constraint_schema
character varying
unique_constraint_name
character varying
match_option
character varying
NONE
.update_rule
character varying
NO ACTION
.delete_rule
character varying
CASCADE
or NO ACTION
.spanner_state
character varying
-
BACKFILLING_INDEXES
: Indexes are being backfilled. -
VALIDATING_DATA
: Existing data and new writes are being validated. -
WAITING_FOR_COMMIT
: The foreign key bulk operations have completed successfully, or none were needed, but the foreign key is still pending. -
COMMITTED
: The schema change was committed.
role_change_stream_grants
This row-filtered view lists the SELECT
privileges granted on all change
streams to any database role, including public
. Principals that have
database-level IAM permissions and principals who have been
granted access to the spanner_info_reader
system role or to members of that
role can see all rows in this view. All other principals can see only privileges
granted on change streams to the current database role and to roles of which the
current database role is a member, not including public
.
Column name | Type | Description |
---|---|---|
grantor
|
character varying
|
Not used. Always NULL
. |
grantee
|
character varying
|
The name of the database role to which this privilege is granted. |
change_stream_catalog
|
character varying
|
The database name. |
change_stream_schema
|
character varying
|
The name of the schema that contains the change stream.
The default is public
for PostgreSQL-dialect databases. |
change_stream_name
|
character varying
|
The name of the change stream. |
privilege_type
|
character varying
|
The type of the privilege ( SELECT
only). |
is_grantable
|
character varying
|
Not used. Always NO
. |
role_column_grants
This row-filtered view lists all fine-grained access control privileges granted on all columns
to any database role, including public
. Principals that have database-level
IAM permissions and principals who have been granted access to the spanner_info_reader
system role or to members of that role can see all rows in
this view. All other principals can see only privileges granted on columns to
the current database role and to roles of which the current database role is a
member, not including public
.
The view includes the SELECT
, INSERT
, and UPDATE
privileges that the
column inherits from the table or view that contains the column.
Column name | Type | Description |
---|---|---|
grantor
|
character varying
|
Not used. Always NULL
. |
grantee
|
character varying
|
The name of the database role to which this privilege is granted. |
table_catalog
|
character varying
|
The database name. |
table_schema
|
character varying
|
The name of the schema that contains the table or view. The
default is public
for PostgreSQL-dialect databases. |
table_name
|
character varying
|
The name of the table or view that contains the column. |
column_name
|
character varying
|
The name of the column. |
privilege_type
|
character varying
|
The type of the privilege ( SELECT
, INSERT
, or UPDATE
). |
is_grantable
|
character varying
|
Not used. Always NO
. |
role_routine_grants
This row-filtered view lists the EXECUTE
privileges granted on all change
stream read functions to any database role, including public
. Principals that have
database-level IAM permissions and principals who have been granted access to the spanner_info_reader
system role or to members of that role can see all rows in
this view. All other principals can see only privileges granted on change stream
read functions to the current database role and to roles of which the current
database role is a member, not including public
.
Column name | Type | Description |
---|---|---|
grantor
|
character varying
|
Not used. Always NULL
. |
grantee
|
character varying
|
The name of the role that the privilege was granted to. |
specific_catalog
|
character varying
|
The database name. |
specific_schema
|
character varying
|
The name of the routine's schema. For PostgreSQL-dialect databases, the default
is public
. |
specific_name
|
character varying
|
The name of the routine. Uniquely identifies the routine even if its name is overloaded. |
routine_catalog
|
character varying
|
The database name. |
routine_schema
|
character varying
|
The name of the routine's schema. The default is public
for PostgreSQL-dialect databases. |
routine_name
|
character varying
|
The name of the routine. (Might be duplicated in case of overloading.) |
privilege_type
|
character varying
|
The type of the privilege granted. Always EXECUTE
. |
is_grantable
|
character varying
|
Not used. Always NO
. |
role_table_grants
This row-filtered view lists all fine-grained access control privileges granted on all tables
and views to any database role, including public
. Principals that have
database-level IAM permissions and principals who have been
granted access to the spanner_info_reader
system role or to members of that
role can see all rows in this view. All other principals can see only privileges
granted on tables and views to the current database role and to roles of which
the current database role is a member, not including public
.
Column name | Type | Description |
---|---|---|
grantor
|
character varying
|
Not used. Always NULL
. |
grantee
|
character varying
|
The name of the database role to which this privilege is granted. |
table_catalog
|
character varying
|
The database name. |
table_schema
|
character varying
|
The name of the schema that contains the table or view. The default is public
for PostgreSQL-dialect databases. |
table_name
|
character varying
|
The name of the table or view. |
privilege_type
|
character varying
|
The type of the privilege ( SELECT
, INSERT
, UPDATE
, or DELETE
). |
is_grantable
|
character varying
|
Not used. Always NO
. |
with_hierarchy
|
character varying
|
Not used. Always NULL
. |
routine_options
This row-filtered view contains one row for each option for each defined change stream read function.
Principals that have database-level IAM permissions and principals who
have been granted access to the spanner_info_reader
system role or to members
of that role can see all rows in this view. All other principals can see only
options for change stream read functions on which the EXECUTE
fine-grained access control
privilege is granted to the current database role, to roles of which the current
database role is a member, or to public
.
specific_catalog
character varying
specific_schema
character varying
public
for PostgreSQL-dialect databases.specific_name
character varying
option_name
character varying
option_type
character varying
- For built-in types, the name of the data type.
- For arrays, the value
ARRAY
.
option_value
character varying
routine_privileges
This row-filtered view lists all fine-grained access control privileges granted on all change
stream read functions to any database role, including public
. Principals that
have database-level IAM permissions and principals who have been
granted access to the spanner_info_reader
system role or to members of that
role can see all rows in this view. All other principals can see only privileges
granted on change stream read functions to the current database role, to roles
of which the current database role is a member, or to public
.
Column name | Type | Description |
---|---|---|
grantor
|
character varying
|
Not used. Always NULL
. |
grantee
|
character varying
|
The name of the role that the privilege was granted to. |
specific_catalog
|
character varying
|
The database name. |
specific_schema
|
character varying
|
The name of the routine's schema. For PostgreSQL-dialect databases, the default
is public
. |
specific_name
|
character varying
|
The name of the routine. Uniquely identifies the routine even if its name is overloaded. |
routine_catalog
|
character varying
|
The database name. |
routine_schema
|
character varying
|
The name of the routine's schema. The default is public
. |
routine_name
|
character varying
|
The name of the routine. (Might be duplicated if overloaded.) |
privilege_type
|
character varying
|
The type of the privilege granted. |
is_grantable
|
character varying
|
Not used. Always NO
. |
routines
This row-filtered view lists all of a database's change stream read functions.
Principals that have database-level IAM permissions and principals who
have been granted access to the spanner_info_reader
system role or to members
of that role can see all rows in this view. All other principals can see only
change stream read functions on which the EXECUTE
fine-grained access control privilege is
granted to the current database role, to roles of which the current database
role is a member, or to public
.
specific_catalog
character varying
specific_schema
character varying
public
for PostgreSQL-dialect databases.specific_name
character varying
routine_catalog
character varying
routine_schema
character varying
routine_name
character varying
routine_type
character varying
FUNCTION
or PROCEDURE
). Always FUNCTION
module_catalog
character varying
NULL
.module_schema
character varying
NULL
.module_name
character varying
NULL
.udt_catalog
character varying
NULL
.udt_schema
character varying
NULL
.udt_name
character varying
NULL
.data_type
character varying
- For built-in types, the name of the data type.
- For arrays, the value
ARRAY
.
character_maximum_length
bigint
NULL
.character_octet_length
bigint
NULL
.character_set_catalog
character varying
NULL
.character_set_schema
character varying
NULL
.character_set_name
character varying
NULL
.collation_catalog
character varying
NULL
.collation_schema
character varying
NULL
.collation_name
character varying
NULL
.numeric_precision
bigint
NULL
.numeric_precision_radix
bigint
NULL
.numeric_scale
bigint
NULL
.datetime_precision
bigint
NULL
.interval_type
character varying
NULL
.interval_precision
bigint
NULL
.type_udt_catalog
character varying
NULL
.type_udt_schema
character varying
NULL
.type_udt_name
character varying
NULL
.scope_catalog
character varying
NULL
.scope_schema
character varying
NULL
.scope_name
character varying
NULL
.maximum_cardinality
bigint
NULL
.dtd_identifier
character varying
NULL
.routine_body
character varying
SQL
or EXTERNAL
).routine_definition
character varying
routine_body
SQL, empty
otherwise.external_name
character varying
NULL
.external_language
character varying
NULL
.parameter_style
character varying
NULL
.is_deterministic
character varying
NULL
.sql_data_access
character varying
NULL
.is_null_call
character varying
NULL
.sql_path
character varying
NULL
.schema_level_routine
character varying
NULL
.max_dynamic_result_sets
character varying
NULL
.is_user_defined_cast
character varying
NULL
.is_implicitly_invocable
character varying
NULL
.security_type
character varying
INVOKER
is
supported.to_sql_specific_catalog
character varying
NULL
.to_sql_specific_schema
character varying
NULL
.to_sql_specific_name
character varying
NULL
.as_locator
character varying
NULL
.created
timestamp with time zone
NULL
.last_altered
timestamp with time zone
NULL
.new_savepoint_level
character varying
NULL
.is_udt_dependent
character varying
NULL
.result_cast_from_data_type
character varying
NULL
.result_cast_as_locator
character varying
NULL
.result_cast_char_max_length
bigint
NULL
.result_cast_char_octet_length
bigint
NULL
.result_cast_char_set_catalog
character varying
NULL
.result_cast_char_set_schema
character varying
NULL
.result_cast_char_set_name
character varying
NULL
.result_cast_collation_catalog
character varying
NULL
.result_cast_collation_schema
character varying
NULL
.result_cast_collation_name
character varying
NULL
.result_cast_numeric_precision
bigint
NULL
.result_cast_numeric_precision_radix
bigint
NULL
.result_cast_numeric_scale
bigint
NULL
.result_cast_datetime_precision
bigint
NULL
.result_cast_interval_type
character varying
NULL
.result_cast_interval_precision
bigint
NULL
.result_cast_type_udt_catalog
character varying
NULL
.result_cast_type_udt_schema
character varying
NULL
.result_cast_type_udt_name
character varying
NULL
.result_cast_scope_catalog
character varying
NULL
.result_cast_scope_schema
character varying
NULL
.result_cast_scope_name
character varying
NULL
.result_cast_maximum_cardinality
bigint
NULL
.result_cast_dtd_identifier
character varying
NULL
. schemata
The information_schema.schemata
view contains one row for each schema in the
current database. The schemas include the information schema and a default
schema named public
.
Column name | Type | Description |
---|---|---|
catalog_name
|
character varying
|
The database name. |
schema_name
|
character varying
|
The name of the schema. This is set to public
for the default schema
and non-empty for named schemas. |
schema_owner
|
character varying
|
The name of the owner of the schema. |
default_character_set_catalog
|
character varying
|
Not used. |
default_character_set_schema
|
character varying
|
Not used. |
default_character_set_name
|
character varying
|
Not used. |
sql_path
|
character varying
|
Not used. |
effective_timestamp
|
timestamp with timezone
|
The timestamp at which all the data in this schema became effective. This is used only for the default schema. |
sequences
The information_schema.sequences
view contains the sequences
metadata.
Column name | Type | Description |
---|---|---|
sequence_catalog
|
character varying
|
The database name. |
sequence_schema
|
character varying
|
The name of the sequence's schema. The default is public
for a PostgreSQL-dialect database. |
sequence_name
|
character varying
|
The name of the sequence. |
data_type
|
character varying
|
Sequence only supports int8
. |
numeric_precision
|
bigint
|
Not used. The value is always `NULL`. |
numeric_precision_radix
|
bigint
|
Not used. The value is always `NULL`. |
numeric_scale
|
bigint
|
Not used. The value is always `NULL`. |
start_value
|
bigint
|
Not used. The value is always `NULL`. |
minimum_value
|
bigint
|
Not used. The value is always `NULL`. |
maximum_value
|
bigint
|
Not used. The value is always `NULL`. |
increment
|
bigint
|
Not used. The value is always `NULL`. |
cycle_option
|
character varying
|
The only option that sequence
accepts is no
. |
sequence_kind
|
character varying
|
The kind of sequence. bit_reversed_positive
is the only
acceptable value. |
counter_start_value
|
bigint
|
Starting value of the sequence counter. |
skip_range_min
|
bigint
|
The minimum value in the skipped range. This value is NULL
if not set. |
skip_range_max
|
bigint
|
The maximum value in the skipped range. This value is NULL
if not set. |
spanner_statistics
This table lists the available query optimizer statistics packages.
Column name | Type | Description |
---|---|---|
catalog_name
|
character varying
|
The database name. |
schema_name
|
character varying
|
The name of the schema. The default schema value is public
. |
package_name
|
character varying
|
The name of the statistics package. |
allow_gc
|
character varying
|
Whether the statistics package is exempted from garbage collection. In
accordance with the SQL standard, the string is either YES
or NO
, rather than a Boolean value. This attribute must be set
to NO
before you can reference the statistics package in a
hint or through the client API. |
table_constraints
This view contains all constraints belonging to tables that the current user has
access to (other than SELECT
).
constraint_catalog
character varying
constraint_schema
character varying
constraint_name
character varying
table_catalog
character varying
table_schema
character varying
table_name
character varying
constraint_type
character varying
-
CHECK
-
FOREIGN KEY
-
PLACEMENT KEY
-
PRIMARY KEY
-
UNIQUE
is_deferrable
character varying
NO
.initially_deferred
character varying
NO
.enforced
character varying
YES
or NO
, rather than a
Boolean value. table_privileges
This row-filtered view lists all fine-grained access control privileges granted on all tables
and views to any database role, including public
. Principals that have
database-level IAM permissions and principals who have been
granted access to the spanner_info_reader
system role or to members of that
role can see all rows in this view. All other principals can see only privileges
granted on tables and views to the current database role, to roles of which the
current database role is a member, or to public
.
Column name | Type | Description |
---|---|---|
grantor
|
character varying
|
Not used. Always NULL
. |
grantee
|
character varying
|
The name of the database role to which this privilege is granted. |
table_catalog
|
character varying
|
The database name. |
table_schema
|
character varying
|
The name of the schema that contains the table or view.
The default is public
for PostgreSQL-dialect databases. |
table_name
|
character varying
|
The name of the table or view. |
privilege_type
|
character varying
|
The type of the privilege ( SELECT
, INSERT
, UPDATE
, or DELETE
). |
is_grantable
|
character varying
|
Not used. Always NO
. |
that have_hierarchy
|
character varying
|
Not used. Always NULL
. |
tables
This row-filtered view lists all the tables and view that are in the current database.
Principals that have database-level IAM permissions and principals who
have been granted access to the spanner_info_reader
system role or to members
of that role can see all tables and views. All other principals can see only tables
that meet either of the following requirements:
- The
SELECT
,INSERT
,UPDATE
, orDELETE
fine-grained access control privileges are granted on the table to the current database role, to roles of which the current database role is a member, or topublic
. - The
SELECT
,INSERT
, orUPDATE
privileges are granted on any table column to the current database role, to roles of which the current database role is a member, or topublic
.
table_catalog
character varying
table_schema
character varying
table_name
character varying
table_type
character varying
self_referencing_column_name
character varying
reference_generation
character varying
user_defined_type_catalog
character varying
user_defined_type_schema
character varying
user_defined_type_name
character varying
is_insertable_into
character varying
is_typed
character varying
commit_action
character varying
parent_table_name
character varying
NULL
.on_delete_action
character varying
CASCADE
or NO ACTION
for
interleaved tables, and NULL
otherwise. See TABLE statements
for more information.spanner_state
character varying
A table can go through multiple states during creation, if bulk operations are involved, for example, when the table is created with a foreign key that requires backfilling of its referenced index. Possible states are:
-
ADDING_FOREIGN_KEY
: Adding the table's foreign keys -
WAITING_FOR_COMMIT
: Finalizing the schema change -
COMMITTED
: The schema change to create the table has been committed. You cannot write to the table until the change is committed. -
NULL
: Tables or views that are not base tables.
interleave_type
character varying
-
IN
: AnINTERLEAVE IN
table that has no parent-child relationship. A row in this table can exist regardless of the existence of its parent table row. -
IN PARENT
: AnINTERLEAVE IN PARENT
table that has a parent-child relationship. A row in this table requires the existence of its parent table row.
row_deletion_policy_expression
character varying
ROW
DELETION POLICY
. table_synonyms
This table lists synonym information for the table.
Column name | Type | Description |
---|---|---|
CATALOG
|
STRING
|
Name of the catalog containing the table. |
SCHEMA
|
STRING
|
Name of the schema containing the table. |
TABLE_NAME
|
STRING
|
Name of the table. |
SYNONYM_CATALOG
|
STRING
|
The name of the catalog for the synonym. |
SYNONYM_SCHEMA
|
STRING
|
The name of the schema for the synonym. |
SYNONYM_TABLE_NAME
|
STRING
|
The name of the table for the synonym. |
views
This row-filtered view lists all views in the current database. Principals that
have database-level IAM permissions and principals who have been
granted access to the spanner_info_reader
system role or to members of that
role can see all views. All other principals can see only views that have the SELECT
fine-grained access control privilege granted on them to the current database role,
to roles of which the current database role is a member, or to public
.
Column name | Type | Description |
---|---|---|
table_catalog
|
character varying
|
The database name. |
table_schema
|
character varying
|
The name of the schema. The default value is public
. |
table_name
|
character varying
|
The name of the view. |
view_definition
|
character varying
|
The SQL text of the query that defines the view. |
check_option
|
character varying
|
Not used. |
is_updatable
|
character varying
|
Not used. |
is_insertable_into
|
character varying
|
Not used. |
is_trigger_updatable
|
character varying
|
Not used. |
is_trigger_deletable
|
character varying
|
Not used. |
is_trigger_insertable_into
|
character varying
|
Not used. |
security_type
|
character varying
|
The security type of the view. Either INVOKER
or DEFINER
. For more information, see About views . |
Examples
Return information about each table in the user's schema:
SELECT
t
.
table_schema
,
t
.
table_catalog
,
t
.
table_name
,
t
.
parent_table_name
FROM
information_schema
.
tables
AS
t
WHERE
t
.
table_schema
NOT
IN
(
'pg_catalog'
,
'information_schema'
,
'SPANNER_SYS'
)
AND
t
.
table_type
=
'BASE TABLE'
ORDER
BY
t
.
table_catalog
,
t
.
table_schema
,
t
.
table_name
Return the name of all tables and views in the information_schema
for
PostgreSQL-dialect databases:
SELECT
table_name
FROM
information_schema
.
tables
WHERE
table_schema
=
"information_schema"
Return information about columns in the user table my_table
in the default schema:
SELECT
t
.
ordinal_position
,
t
.
column_name
,
t
.
data_type
,
t
.
spanner_type
,
t
.
is_nullable
FROM
information_schema
.
columns
AS
t
WHERE
t
.
table_schema
=
'public'
AND
t
.
table_name
=
'my_table'
ORDER
BY
t
.
ordinal_position
Return information about each index in the default schema in the current database: ```postgresql SELECT t.table_name, t.index_name, t.parent_table_name FROM information_schema.indexes AS t WHERE t.table_schema = 'public' AND t.index_type != 'PRIMARY_KEY' ORDER BY t.table_schema, t.table_name, t.index_name
Return columns that use non-default options in the default schema:
SELECT
t
.
table_name
,
t
.
column_name
,
t
.
option_type
,
t
.
option_value
,
t
.
option_name
FROM
information_schema
.
column_options
AS
t
WHERE
t
.
table_schema
=
'public'
ORDER
BY
t
.
table_schema
,
t
.
table_name
,
t
.
column_name
,
t
.
option_name
Return the current optimizer-related database options:
SELECT
s
.
option_name
,
s
.
option_value
FROM
information_schema
.
database_options
s
WHERE
s
.
schema_name
=
'public'
AND
s
.
option_name
IN
(
'optimizer_version'
,
'optimizer_statistics_package'
)
Return all available statistics packages:
SELECT
*
FROM
information_schema
.
spanner_statistics
;
What's next
- Learn about available Introspection tools to help you investigate database issues.