The Information Schema information schema The information schema consists of a set of views that contain information about the objects defined in the current database. The information schema is defined in the SQL standard and can therefore be expected to be portable and remain stable --- unlike the system catalogs, which are specific to PostgreSQL and are modelled after implementation concerns. The information schema views do not, however, contain information about PostgreSQL-specific features; to inquire about those you need to query the system catalogs or other PostgreSQL-specific views. The Schema The information schema itself is a schema named information_schema. This schema automatically exists in all databases. The owner of this schema is the initial database user in the cluster, and that user naturally has all the privileges on this schema, including the ability to drop it (but the space savings achieved by this are minuscule). By default, the information schema is not in the schema search path, so you need to access all objects in it through qualified names. Since the names of some of the objects in the information schema are generic names that might occur in user applications, you should be careful if you want to put the information schema in the path. Data Types The columns of the information schema views use special data types that are defined in the information schema. These are defined as simple domains over ordinary built-in types. You should not use these types for work outside the information schema, but your applications must be prepared for them if they select from the information schema. These types are: cardinal_number A nonnegative integer. character_data A character string (without specific maximum length). sql_identifier A character string. This type is used for SQL identifiers, the type character_data is used for any other kind of text data. time_stamp A domain over the type timestamp Every column in the information schema has one of these four types. Boolean (true/false) data is represented in the information schema by a column of type character_data that contains either YES or NO. (The information schema was invented before the type boolean was added to the SQL standard, so this convention is necessary to keep the information schema backward compatible.) <literal>information_schema_catalog_name</literal> information_schema_catalog_name is a table that always contains one row and one column containing the name of the current database (current catalog, in SQL terminology). <literal>information_schema_catalog_name</literal> Columns Name Data Type Description catalog_name sql_identifier Name of the database that contains this information schema
<literal>applicable_roles</literal> The view applicable_roles identifies all groups that the current user is a member of. (A role is the same thing as a group.) Generally, it is better to use the view enabled_roles instead of this one; see also there. <literal>applicable_roles</literal> Columns Name Data Type Description grantee sql_identifier Always the name of the current user role_name sql_identifier Name of a group is_grantable character_data Applies to a feature not available in PostgreSQL
<literal>check_constraints</literal> The view check_constraints contains all check constraints, either defined on a table or on a domain, that are owned by the current user. (The owner of the table or domain is the owner of the constraint.) <literal>check_constraints</literal> Columns Name Data Type Description constraint_catalog sql_identifier Name of the database containing the constraint (always the current database) constraint_schema sql_identifier Name of the schema containing the constraint constraint_name sql_identifier Name of the constraint check_clause character_data The check expression of the check constraint
<literal>column_domain_usage</literal> The view column_domain_usage identifies all columns (of a table or a view) that make use of some domain defined in the current database and owned by the current user. <literal>column_domain_usage</literal> Columns Name Data Type Description domain_catalog sql_identifier Name of the database containing the domain (always the current database) domain_schema sql_identifier Name of the schema containing the domain domain_name sql_identifier Name of the domain table_catalog sql_identifier Name of the database containing the table (always the current database) table_schema sql_identifier Name of the schema containing the table table_name sql_identifier Name of the table column_name sql_identifier Name of the column
<literal>column_privileges</literal> The view column_privileges identifies all privileges granted on columns to the current user or by the current user. There is one row for each combination of column, grantor, and grantee. Privileges granted to groups are identified in the view role_column_grants. In PostgreSQL, you can only grant privileges on entire tables, not individual columns. Therefore, this view contains the same information as table_privileges, just represented through one row for each column in each appropriate table, but it only covers privilege types where column granularity is possible: SELECT, INSERT, UPDATE, REFERENCES. If you want to make your applications fit for possible future developments, it is generally the right choice to use this view instead of table_privileges if one of those privilege types is concerned. <literal>column_privileges</literal> Columns Name Data Type Description grantor sql_identifier Name of the user that granted the privilege grantee sql_identifier Name of the user or group that the privilege was granted to table_catalog sql_identifier Name of the database that contains the table that contains the column (always the current database) table_schema sql_identifier Name of the schema that contains the table that contains the column table_name sql_identifier Name of the table that contains the column column_name sql_identifier Name of the column privilege_type character_data Type of the privilege: SELECT, INSERT, UPDATE, or REFERENCES is_grantable character_data YES if the privilege is grantable, NO if not
Note that the column grantee makes no distinction between users and groups. If you have users and groups with the same name, there is unfortunately no way to distinguish them. A future version of PostgreSQL will possibly prohibit having users and groups with the same name.
<literal>column_udt_usage</literal> The view column_udt_usage identifies all columns that use data types owned by the current user. Note that in PostgreSQL, built-in data types behave like user-defined types, so they are included here as well. See also for details. <literal>column_udt_usage</literal> Columns Name Data Type Description udt_catalog sql_identifier Name of the database that the column data type (the underlying type of the domain, if applicable) is defined in (always the current database) udt_schema sql_identifier Name of the schema that the column data type (the underlying type of the domain, if applicable) is defined in udt_name sql_identifier Name of the column data type (the underlying type of the domain, if applicable) table_catalog sql_identifier Name of the database containing the table (always the current database) table_schema sql_identifier Name of the schema containing the table table_name sql_identifier Name of the table column_name sql_identifier Name of the column
<literal>columns</literal> The view columns contains information about all table columns (or view columns) in the database. System columns (oid, etc.) are not included. Only those columns are shown that the current user has access to (by way of being the owner or having some privilege). <literal>columns</literal> Columns Name Data Type Description table_catalog sql_identifier Name of the database containing the table (always the current database) table_schema sql_identifier Name of the schema containing the table table_name sql_identifier Name of the table column_name sql_identifier Name of the column ordinal_position cardinal_number Ordinal position of the column within the table (count starts at 1) column_default character_data Default expression of the column (null if the current user is not the owner of the table containing the column) is_nullable character_data YES if the column is possibly nullable, NO if it is known not nullable. A not-null constraint is one way a column can be known not nullable, but there may be others. data_type character_data Data type of the column, if it is a built-in type, or ARRAY if it is some array (in that case, see the view element_types), else USER-DEFINED (in that case, the type is identified in udt_name and associated columns). If the column is based on a domain, this column refers to the type underlying the domain (and the domain is identified in domain_name and associated columns). character_maximum_length cardinal_number If data_type identifies a character or bit string type, the declared maximum length; null for all other data types or if no maximum length was declared. character_octet_length cardinal_number If data_type identifies a character type, the maximum possible length in octets (bytes) of a datum (this should not be of concern to PostgreSQL users); null for all other data types. numeric_precision cardinal_number If data_type identifies a numeric type, this column contains the (declared or implicit) precision of the type for this column. The precision indicates the number of significant digits. It may be expressed in decimal (base 10) or binary (base 2) terms, as specified in the column numeric_precision_radix. For all other data types, this column is null. numeric_precision_radix cardinal_number If data_type identifies a numeric type, this column indicates in which base the values in the columns numeric_precision and numeric_scale are expressed. The value is either 2 or 10. For all other data types, this column is null. numeric_scale cardinal_number If data_type identifies an exact numeric type, this column contains the (declared or implicit) scale of the type for this column. The scale indicates the number of significant digits to the right of the decimal point. It may be expressed in decimal (base 10) or binary (base 2) terms, as specified in the column numeric_precision_radix. For all other data types, this column is null. datetime_precision cardinal_number If data_type identifies a date, time, or interval type, the declared precision; null for all other data types or if no precision was declared. interval_type character_data Not yet implemented interval_precision character_data Not yet implemented character_set_catalog sql_identifier Applies to a feature not available in PostgreSQL character_set_schema sql_identifier Applies to a feature not available in PostgreSQL character_set_name sql_identifier Applies to a feature not available in PostgreSQL collation_catalog sql_identifier Applies to a feature not available in PostgreSQL collation_schema sql_identifier Applies to a feature not available in PostgreSQL collation_name sql_identifier Applies to a feature not available in PostgreSQL domain_catalog sql_identifier If the column has a domain type, the name of the database that the domain is defined in (always the current database), else null. domain_schema sql_identifier If the column has a domain type, the name of the schema that the domain is defined in, else null. domain_name sql_identifier If the column has a domain type, the name of the domain, else null. udt_catalog sql_identifier Name of the database that the column data type (the underlying type of the domain, if applicable) is defined in (always the current database) udt_schema sql_identifier Name of the schema that the column data type (the underlying type of the domain, if applicable) is defined in udt_name sql_identifier Name of the column data type (the underlying type of the domain, if applicable) scope_catalog sql_identifier Applies to a feature not available in PostgreSQL scope_schema sql_identifier Applies to a feature not available in PostgreSQL scope_name sql_identifier Applies to a feature not available in PostgreSQL maximum_cardinality cardinal_number Always null, because arrays always have unlimited maximum cardinality in PostgreSQL dtd_identifier sql_identifier An identifier of the data type descriptor of the column, unique among the data type descriptors pertaining to the table. This is mainly useful for joining with other instances of such identifiers. (The specific format of the identifier is not defined and not guaranteed to remain the same in future versions.) is_self_referencing character_data Applies to a feature not available in PostgreSQL
Since data types can be defined in a variety of ways in SQL, and PostgreSQL contains additional ways to define data types, their representation in the information schema can be somewhat difficult. The column data_type is supposed to identify the underlying built-in type of the column. In PostgreSQL, this means that the type is defined in the system catalog schema pg_catalog. This column may be useful if the application can handle the well-known built-in types specially (for example, format the numeric types differently or use the data in the precision columns). The columns udt_name, udt_schema, and udt_catalog always identify the underlying data type of the column, even if the column is based on a domain. (Since PostgreSQL treats built-in types like user-defined types, built-in types appear here as well. This is an extension of the SQL standard.) These columns should be used if an application wants to process data differently according to the type, because in that case it wouldn't matter if the column is really based on a domain. If the column is based on a domain, the identity of the domain is stored in the columns domain_name, domain_schema, and domain_catalog. If you want to pair up columns with their associated data types and treat domains as separate types, you could write coalesce(domain_name, udt_name), etc.
<literal>constraint_column_usage</literal> The view constraint_column_usage identifies all columns in the current database that are used by some constraint. Only those columns are shown that are contained in a table owned the current user. For a check constraint, this view identifies the columns that are used in the check expression. For a foreign key constraint, this view identifies the columns that the foreign key references. For a unique or primary key constraint, this view identifies the constrained columns. <literal>constraint_column_usage</literal> Columns Name Data Type Description table_catalog sql_identifier Name of the database that contains the table that contains the column that is used by some constraint (always the current database) table_schema sql_identifier Name of the schema that contains the table that contains the column that is used by some constraint table_name sql_identifier Name of the table that contains the column that is used by some constraint column_name sql_identifier Name of the column that is used by some constraint constraint_catalog sql_identifier Name of the database that contains the constraint (always the current database) constraint_schema sql_identifier Name of the schema that contains the constraint constraint_name sql_identifier Name of the constraint
<literal>constraint_table_usage</literal> The view constraint_table_usage identifies all tables in the current database that are used by some constraint and are owned by the current user. (This is different from the view table_constraints, which identifies all table constraints along with the table they are defined on.) For a foreign key constraint, this view identifies the table that the foreign key references. For a unique or primary key constraint, this view simply identifies the table the constraint belongs to. Check constraints and not-null constraints are not included in this view. <literal>constraint_table_usage</literal> Columns Name Data Type Description table_catalog sql_identifier Name of the database that contains the table that is used by some constraint (always the current database) table_schema sql_identifier Name of the schema that contains the table that is used by some constraint table_name sql_identifier Name of the table that is used by some constraint constraint_catalog sql_identifier Name of the database that contains the constraint (always the current database) constraint_schema sql_identifier Name of the schema that contains the constraint constraint_name sql_identifier Name of the constraint
<literal>data_type_privileges</literal> The view data_type_privileges identifies all data type descriptors that the current user has access to, by way of being the owner of the described object or having some privilege for it. A data type descriptor is generated whenever a data type is used in the definition of a table column, a domain, or a function (as parameter or return type) and stores some information about how the data type is used in that instance (for example, the declared maximum length, if applicable). Each data type descriptors is assigned an arbitrary identifier that is unique among the data type descriptor identifiers assigned for one object (table, domain, function). This view is probably not useful for applications, but it is used to define some other views in the information schema. <literal>domain_constraints</literal> Columns Name Data Type Description object_catalog sql_identifier Name of the database that contains the described object (always the current database) object_schema sql_identifier Name of the schema that contains the described object object_name sql_identifier Name of the described object object_type character_data The type of the described object: one of TABLE (the data type descriptor pertains to a column of that table), DOMAIN (the data type descriptors pertains to that domain), ROUTINE (the data type descriptor pertains to a parameter or the return data type of that function). dtd_identifier sql_identifier The identifier of the data type descriptor, which is unique among the data type descriptors for that same object.
<literal>domain_constraints</literal> The view domain_constraints contains all constraints belonging to domains owned by the current user. <literal>domain_constraints</literal> Columns Name Data Type Description constraint_catalog sql_identifier Name of the database that contains the constraint (always the current database) constraint_schema sql_identifier Name of the schema that contains the constraint constraint_name sql_identifier Name of the constraint domain_catalog sql_identifier Name of the database that contains the domain (always the current database) domain_schema sql_identifier Name of the schema that contains the domain domain_name sql_identifier Name of the domain is_deferrable character_data YES if the constraint is deferrable, NO if not initially_deferred character_data YES if the constraint is deferrable and initially deferred, NO if not
<literal>domain_udt_usage</literal> The view domain_udt_usage identifies all columns that use data types owned by the current user. Note that in PostgreSQL, built-in data types behave like user-defined types, so they are included here as well. <literal>domain_udt_usage</literal> Columns Name Data Type Description udt_catalog sql_identifier Name of the database that the domain data type is defined in (always the current database) udt_schema sql_identifier Name of the schema that the domain data type is defined in udt_name sql_identifier Name of the domain data type domain_catalog sql_identifier Name of the database that contains the domain (always the current database) domain_schema sql_identifier Name of the schema that contains the domain domain_name sql_identifier Name of the domain
<literal>domains</literal> The view domains contains all domains defined in the current database. <literal>domains</literal> Columns Name Data Type Description domain_catalog sql_identifier Name of the database that contains the domain (always the current database) domain_schema sql_identifier Name of the schema that contains the domain domain_name sql_identifier Name of the domain data_type character_data Data type of the domain, if it is a built-in type, or ARRAY if it is some array (in that case, see the view element_types), else USER-DEFINED (in that case, the type is identified in udt_name and associated columns). character_maximum_length cardinal_number If the domain has a character or bit string type, the declared maximum length; null for all other data types or if no maximum length was declared. character_octet_length cardinal_number If the domain has a character type, the maximum possible length in octets (bytes) of a datum (this should not be of concern to PostgreSQL users); null for all other data types. character_set_catalog sql_identifier Applies to a feature not available in PostgreSQL character_set_schema sql_identifier Applies to a feature not available in PostgreSQL character_set_name sql_identifier Applies to a feature not available in PostgreSQL collation_catalog sql_identifier Applies to a feature not available in PostgreSQL collation_schema sql_identifier Applies to a feature not available in PostgreSQL collation_name sql_identifier Applies to a feature not available in PostgreSQL numeric_precision cardinal_number If the domain has a numeric type, this column contains the (declared or implicit) precision of the type for this column. The precision indicates the number of significant digits. It may be expressed in decimal (base 10) or binary (base 2) terms, as specified in the column numeric_precision_radix. For all other data types, this column is null. numeric_precision_radix cardinal_number If the domain has a numeric type, this column indicates in which base the values in the columns numeric_precision and numeric_scale are expressed. The value is either 2 or 10. For all other data types, this column is null. numeric_scale cardinal_number If the domain has an exact numeric type, this column contains the (declared or implicit) scale of the type for this column. The scale indicates the number of significant digits to the right of the decimal point. It may be expressed in decimal (base 10) or binary (base 2) terms, as specified in the column numeric_precision_radix. For all other data types, this column is null. datetime_precision cardinal_number If the domain has a date, time, or interval type, the declared precision; null for all other data types or if no precision was declared. interval_type character_data Not yet implemented interval_precision character_data Not yet implemented domain_default character_data Default expression of the domain udt_catalog sql_identifier Name of the database that the domain data type is defined in (always the current database) udt_schema sql_identifier Name of the schema that the domain data type is defined in udt_name sql_identifier Name of the domain data type scope_catalog sql_identifier Applies to a feature not available in PostgreSQL scope_schema sql_identifier Applies to a feature not available in PostgreSQL scope_name sql_identifier Applies to a feature not available in PostgreSQL maximum_cardinality cardinal_number Always null, because arrays always have unlimited maximum cardinality in PostgreSQL dtd_identifier sql_identifier An identifier of the data type descriptor of the domain, unique among the data type descriptors pertaining to the domain (which is trivial, because a domain only contains one data type descriptor). This is mainly useful for joining with other instances of such identifiers. (The specific format of the identifier is not defined and not guaranteed to remain the same in future versions.)
<literal>element_types</literal> The view element_types contains the data type descriptors of the elements of arrays. When a table column, domain, function parameter, or function return value is defined to be of an array type, the respective information schema view only contains ARRAY in the column data_type. To obtain information on the element type of the array, you can join the respective view with this view. For example, to show the columns of a table with data types and array element types, if applicable, you could do SELECT c.column_name, c.data_type, e.data_type AS element_type FROM information_schema.columns c LEFT JOIN information_schema.element_types e ON ((c.table_catalog, c.table_schema, c.table_name, 'TABLE', c.dtd_identifier) = (e.object_catalog, e.object_schema, e.object_name, e.object_type, e.array_type_identifier)) WHERE c.table_schema = '...' AND c.table_name = '...' ORDER BY c.ordinal_position; This view only includes objects that the current user has access to, by way of being the owner or having some privilege. <literal>element_types</literal> Columns Name Data Type Description object_catalog sql_identifier Name of the database that contains the object that uses the array being described (always the current database) object_schema sql_identifier Name of the schema that contains the object that uses the array being described object_name sql_identifier Name of the object that uses the array being described object_type character_data The type of the object that uses the array being described: one of TABLE (the array is used by a column of that table), DOMAIN (the array is used by that domain), ROUTINE (the array is used by a parameter or the return data type of that function). array_type_identifier sql_identifier The identifier of the data type descriptor of the array being described. Use this to join with the dtd_identifier columns of other information schema views. data_type character_data Data type of the array elements, if it is a built-in type, else USER-DEFINED (in that case, the type is identified in udt_name and associated columns). character_maximum_length cardinal_number Always null, since this information is not applied to array element data types in PostgreSQL character_octet_length cardinal_number Always null, since this information is not applied to array element data types in PostgreSQL character_set_catalog sql_identifier Applies to a feature not available in PostgreSQL character_set_schema sql_identifier Applies to a feature not available in PostgreSQL character_set_name sql_identifier Applies to a feature not available in PostgreSQL collation_catalog sql_identifier Applies to a feature not available in PostgreSQL collation_schema sql_identifier Applies to a feature not available in PostgreSQL collation_name sql_identifier Applies to a feature not available in PostgreSQL numeric_precision cardinal_number Always null, since this information is not applied to array element data types in PostgreSQL numeric_precision_radix cardinal_number Always null, since this information is not applied to array element data types in PostgreSQL numeric_scale cardinal_number Always null, since this information is not applied to array element data types in PostgreSQL datetime_precision cardinal_number Always null, since this information is not applied to array element data types in PostgreSQL interval_type character_data Always null, since this information is not applied to array element data types in PostgreSQL interval_precision character_data Always null, since this information is not applied to array element data types in PostgreSQL domain_default character_data Not yet implemented udt_catalog sql_identifier Name of the database that the data type of the elements is defined in (always the current database) udt_schema sql_identifier Name of the schema that the data type of the elements is defined in udt_name sql_identifier Name of the data type of the elements scope_catalog sql_identifier Applies to a feature not available in PostgreSQL scope_schema sql_identifier Applies to a feature not available in PostgreSQL scope_name sql_identifier Applies to a feature not available in PostgreSQL maximum_cardinality cardinal_number Always null, because arrays always have unlimited maximum cardinality in PostgreSQL dtd_identifier sql_identifier An identifier of the data type descriptor of the element. This is currently not useful.
<literal>enabled_roles</literal> The view enabled_roles identifies all groups that the current user is a member of. (A role is the same thing as a group.) The difference between this view and applicable_roles is that in the future there may be a mechanism to enable and disable groups during a session. In that case this view identifies those groups that are currently enabled. <literal>enabled_roles</literal> Columns Name Data Type Description role_name sql_identifier Name of a group
<literal>key_column_usage</literal> The view key_column_usage identifies all columns in the current database that are restricted by some unique, primary key, or foreign key constraint. Check constraints are not included in this view. Only those columns are shown that are contained in a table owned the current user. <literal>key_column_usage</literal> Columns Name Data Type Description constraint_catalog sql_identifier Name of the database that contains the constraint (always the current database) constraint_schema sql_identifier Name of the schema that contains the constraint constraint_name sql_identifier Name of the constraint table_catalog sql_identifier Name of the database that contains the table that contains the column that is restricted by some constraint (always the current database) table_schema sql_identifier Name of the schema that contains the table that contains the column that is restricted by some constraint table_name sql_identifier Name of the table that contains the column that is restricted by some constraint column_name sql_identifier Name of the column that is restricted by some constraint ordinal_position cardinal_number Ordinal position of the column within the constraint key (count starts at 1)
<literal>parameters</literal> The view parameters contains information about the parameters (arguments) all functions in the current database. Only those functions are shown that the current user has access to (by way of being the owner or having some privilege). <literal>parameters</literal> Columns Name Data Type Description specific_catalog sql_identifier Name of the database containing the function (always the current database) specific_schema sql_identifier Name of the schema containing the function specific_name sql_identifier The specific name of the function. See for more information. ordinal_position cardinal_number Ordinal position of the parameter in the argument list of the function (count starts at 1) parameter_mode character_data Always IN, meaning input parameter (In the future there might be other parameter modes.) is_result character_data Applies to a feature not available in PostgreSQL as_locator character_data Applies to a feature not available in PostgreSQL parameter_name sql_identifier Always null, since PostgreSQL does not support named parameters data_type character_data Data type of the parameter, if it is a built-in type, or ARRAY if it is some array (in that case, see the view element_types), else USER-DEFINED (in that case, the type is identified in udt_name and associated columns). character_maximum_length cardinal_number Always null, since this information is not applied to parameter data types in PostgreSQL character_octet_length cardinal_number Always null, since this information is not applied to parameter data types in PostgreSQL character_set_catalog sql_identifier Applies to a feature not available in PostgreSQL character_set_schema sql_identifier Applies to a feature not available in PostgreSQL character_set_name sql_identifier Applies to a feature not available in PostgreSQL collation_catalog sql_identifier Applies to a feature not available in PostgreSQL collation_schema sql_identifier Applies to a feature not available in PostgreSQL collation_name sql_identifier Applies to a feature not available in PostgreSQL numeric_precision cardinal_number Always null, since this information is not applied to parameter data types in PostgreSQL numeric_precision_radix cardinal_number Always null, since this information is not applied to parameter data types in PostgreSQL numeric_scale cardinal_number Always null, since this information is not applied to parameter data types in PostgreSQL datetime_precision cardinal_number Always null, since this information is not applied to parameter data types in PostgreSQL interval_type character_data Always null, since this information is not applied to parameter data types in PostgreSQL interval_precision character_data Always null, since this information is not applied to parameter data types in PostgreSQL udt_catalog sql_identifier Name of the database that the data type of the parameter is defined in (always the current database) udt_schema sql_identifier Name of the schema that the data type of the parameter is defined in udt_name sql_identifier Name of the data type of the parameter scope_catalog sql_identifier Applies to a feature not available in PostgreSQL scope_schema sql_identifier Applies to a feature not available in PostgreSQL scope_name sql_identifier Applies to a feature not available in PostgreSQL maximum_cardinality cardinal_number Always null, because arrays always have unlimited maximum cardinality in PostgreSQL dtd_identifier sql_identifier An identifier of the data type descriptor of the parameter, unique among the data type descriptors pertaining to the function. This is mainly useful for joining with other instances of such identifiers. (The specific format of the identifier is not defined and not guaranteed to remain the same in future versions.)
<literal>referential_constraints</literal> The view referential_constraints contains all referential (foreign key) constraints in the current database that belong to a table owned by the current user. <literal>referential_constraints</literal> Columns Name Data Type Description constraint_catalog sql_identifier Name of the database containing the constraint (always the current database) constraint_schema sql_identifier Name of the schema containing the constraint constraint_name sql_identifier Name of the constraint unique_constraint_catalog sql_identifier Name of the database that contains the unique or primary key constraint that the foreign key constraint references (always the current database) unique_constraint_schema sql_identifier Name of the schema that contains the unique or primary key constraint that the foreign key constraint references unique_constraint_name sql_identifier Name of the unique or primary key constraint that the foreign key constraint references match_option character_data Match option of the foreign key constraint: FULL, PARTIAL, or NONE. update_rule character_data Update rule of the foreign key constraint: CASCADE, SET NULL, SET DEFAULT, RESTRICT, or NO ACTION. delete_rule character_data Delete rule of the foreign key constraint: CASCADE, SET NULL, SET DEFAULT, RESTRICT, or NO ACTION.
<literal>role_column_grants</literal> The view role_column_grants identifies all privileges granted on columns to a group that the current user is a member of. Further information can be found under column_privileges. <literal>role_column_grants</literal> Columns Name Data Type Description grantor sql_identifier Name of the user that granted the privilege grantee sql_identifier Name of the group that the privilege was granted to table_catalog sql_identifier Name of the database that contains the table that contains the column (always the current database) table_schema sql_identifier Name of the schema that contains the table that contains the column table_name sql_identifier Name of the table that contains the column column_name sql_identifier Name of the column privilege_type character_data Type of the privilege: SELECT, INSERT, UPDATE, or REFERENCES is_grantable character_data YES if the privilege is grantable, NO if not
<literal>role_routine_grants</literal> The view role_routine_grants identifies all privileges granted on functions to a group that the current user is a member of. Further information can be found under routine_privileges. <literal>role_routine_grants</literal> Columns Name Data Type Description grantor sql_identifier Name of the user that granted the privilege grantee sql_identifier Name of the group that the privilege was granted to specific_catalog sql_identifier Name of the database containing the function (always the current database) specific_schema sql_identifier Name of the schema containing the function specific_name sql_identifier The specific name of the function. See for more information. routine_catalog sql_identifier Name of the database containing the function (always the current database) routine_schema sql_identifier Name of the schema containing the function routine_name sql_identifier Name of the function (may be duplicated in case of overloading) privilege_type character_data Always EXECUTE (the only privilege type for functions) is_grantable character_data YES if the privilege is grantable, NO if not
<literal>role_table_grants</literal> The view role_table_grants identifies all privileges granted on tables or views to a group that the current user is a member of. Further information can be found under table_privileges. <literal>role_table_grants</literal> Columns Name Data Type Description grantor sql_identifier Name of the user that granted the privilege grantee sql_identifier Name of the group that the privilege was granted to table_catalog sql_identifier Name of the database that contains the table (always the current database) table_schema sql_identifier Name of the schema that contains the table table_name sql_identifier Name of the table privilege_type character_data Type of the privilege: SELECT, DELETE, INSERT, UPDATE, REFERENCES, RULE, or TRIGGER is_grantable character_data YES if the privilege is grantable, NO if not with_hierarchy character_data Applies to a feature not available in PostgreSQL
<literal>role_usage_grants</literal> The view role_usage_grants is meant to identify USAGE privileges granted on various kinds of objects to a group that the current user is a member of. In PostgreSQL, this currently only applies to domains, and since domains do not have real privileges in PostgreSQL, this view is empty. Further information can be found under usage_privileges. In the future, this view may contain more useful information. <literal>role_usage_grants</literal> Columns Name Data Type Description grantor sql_identifier In the future, the name of the user that granted the privilege grantee sql_identifier In the future, the name of the group that the privilege was granted to object_catalog sql_identifier Name of the database containing the object (always the current database) object_schema sql_identifier Name of the schema containing the object object_name sql_identifier Name of the object object_type character_data In the future, the type of the object privilege_type character_data Always USAGE is_grantable character_data YES if the privilege is grantable, NO if not
<literal>routine_privileges</literal> The view routine_privileges identifies all privileges granted on functions to the current user or by the current user. There is one row for each combination of function, grantor, and grantee. Privileges granted to groups are identified in the view role_routine_grants. <literal>routine_privileges</literal> Columns Name Data Type Description grantor sql_identifier Name of the user that granted the privilege grantee sql_identifier Name of the user or group that the privilege was granted to specific_catalog sql_identifier Name of the database containing the function (always the current database) specific_schema sql_identifier Name of the schema containing the function specific_name sql_identifier The specific name of the function. See for more information. routine_catalog sql_identifier Name of the database containing the function (always the current database) routine_schema sql_identifier Name of the schema containing the function routine_name sql_identifier Name of the function (may be duplicated in case of overloading) privilege_type character_data Always EXECUTE (the only privilege type for functions) is_grantable character_data YES if the privilege is grantable, NO if not
Note that the column grantee makes no distinction between users and groups. If you have users and groups with the same name, there is unfortunately no way to distinguish them. A future version of PostgreSQL will possibly prohibit having users and groups with the same name.
<literal>routines</literal> The view routines contains all functions in the current database. Only those functions are shown that the current user has access to (by way of being the owner or having some privilege). <literal>routines</literal> Columns Name Data Type Description specific_catalog sql_identifier Name of the database containing the function (always the current database) specific_schema sql_identifier Name of the schema containing the function specific_name sql_identifier The specific name of the function. This is a name that uniquely identifies the function in the schema, even if the real name of the function is overloaded. The format of the specific name is not defined, it should only be used to compare it to other instances of specific routine names. routine_catalog sql_identifier Name of the database containing the function (always the current database) routine_schema sql_identifier Name of the schema containing the function routine_name sql_identifier Name of the function (may be duplicated in case of overloading) routine_type character_data Always FUNCTION (In the future there might be other types of routines.) module_catalog sql_identifier Applies to a feature not available in PostgreSQL module_schema sql_identifier Applies to a feature not available in PostgreSQL module_name sql_identifier Applies to a feature not available in PostgreSQL udt_catalog sql_identifier Applies to a feature not available in PostgreSQL udt_schema sql_identifier Applies to a feature not available in PostgreSQL udt_name sql_identifier Applies to a feature not available in PostgreSQL data_type character_data Return data type of the function, if it is a built-in type, or ARRAY if it is some array (in that case, see the view element_types), else USER-DEFINED (in that case, the type is identified in type_udt_name and associated columns). character_maximum_length cardinal_number Always null, since this information is not applied to return data types in PostgreSQL character_octet_length cardinal_number Always null, since this information is not applied to return data types in PostgreSQL character_set_catalog sql_identifier Applies to a feature not available in PostgreSQL character_set_schema sql_identifier Applies to a feature not available in PostgreSQL character_set_name sql_identifier Applies to a feature not available in PostgreSQL collation_catalog sql_identifier Applies to a feature not available in PostgreSQL collation_schema sql_identifier Applies to a feature not available in PostgreSQL collation_name sql_identifier Applies to a feature not available in PostgreSQL numeric_precision cardinal_number Always null, since this information is not applied to return data types in PostgreSQL numeric_precision_radix cardinal_number Always null, since this information is not applied to return data types in PostgreSQL numeric_scale cardinal_number Always null, since this information is not applied to return data types in PostgreSQL datetime_precision cardinal_number Always null, since this information is not applied to return data types in PostgreSQL interval_type character_data Always null, since this information is not applied to return data types in PostgreSQL interval_precision character_data Always null, since this information is not applied to return data types in PostgreSQL type_udt_catalog sql_identifier Name of the database that the return data type of the function is defined in (always the current database) type_udt_schema sql_identifier Name of the schema that the return data type of the function is defined in type_udt_name sql_identifier Name of the return data type of the function scope_catalog sql_identifier Applies to a feature not available in PostgreSQL scope_schema sql_identifier Applies to a feature not available in PostgreSQL scope_name sql_identifier Applies to a feature not available in PostgreSQL maximum_cardinality cardinal_number Always null, because arrays always have unlimited maximum cardinality in PostgreSQL dtd_identifier sql_identifier An identifier of the data type descriptor of the return data type of this function, unique among the data type descriptors pertaining to the function. This is mainly useful for joining with other instances of such identifiers. (The specific format of the identifier is not defined and not guaranteed to remain the same in future versions.) routine_body character_data If the function is an SQL function, then SQL, else EXTERNAL. routine_definition character_data The source text of the function (null if the current user is not the owner of the function). (According to the SQL standard, this column is only applicable if routine_body is SQL, but in PostgreSQL it will contain whatever source text was specified when the function was created.) external_name character_data If this function is a C function, then the external name (link symbol) of the function; else null. (This works out to be the same value that is shown in routine_definition.) external_language character_data The language the function is written in parameter_style character_data Always GENERAL (The SQL standard defines other parameter styles, which are not available in PostgreSQL.) is_deterministic character_data If the function is declared immutable (called deterministic in the SQL standard), then YES, else NO. (You cannot query the other volatility levels available in PostgreSQL through the information schema.) sql_data_access character_data Always MODIFIES, meaning that the function possibly modifies SQL data. This information is not useful for PostgreSQL. is_null_call character_data If the function automatically returns null if any of its arguments are null, then YES, else NO. sql_path character_data Applies to a feature not available in PostgreSQL schema_level_routine character_data Always YES (The opposite would be a method of a user-defined type, which is a feature not available in PostgreSQL.) max_dynamic_result_sets cardinal_number Applies to a feature not available in PostgreSQL is_user_defined_cast character_data Applies to a feature not available in PostgreSQL is_implicitly_invocable character_data Applies to a feature not available in PostgreSQL security_type character_data If the function runs with the privileges of the current user, then INVOKER, if the function runs with the privileges of the user who defined it, then DEFINER. to_sql_specific_catalog sql_identifier Applies to a feature not available in PostgreSQL to_sql_specific_schema sql_identifier Applies to a feature not available in PostgreSQL to_sql_specific_name sql_identifier Applies to a feature not available in PostgreSQL as_locator character_data Applies to a feature not available in PostgreSQL
<literal>schemata</literal> The view schemata contains all schemas in the current database that are owned by the current user. <literal>schemata</literal> Columns Name Data Type Description catalog_name sql_identifier Name of the database that the schema is contained in (always the current database) schema_name sql_identifier Name of the schema schema_owner sql_identifier Name of the owner of the schema default_character_set_catalog sql_identifier Applies to a feature not available in PostgreSQL default_character_set_schema sql_identifier Applies to a feature not available in PostgreSQL default_character_set_name sql_identifier Applies to a feature not available in PostgreSQL sql_path character_data Applies to a feature not available in PostgreSQL
<literal>sql_features</literal> The table sql_features contains information about which formal features defined in the SQL standard are supported by PostgreSQL. This is the same information that is presented in . There you can also find some additional background information. <literal>sql_features</literal> Columns Name Data Type Description feature_id character_data Identifier string of the feature feature_name character_data Descriptive name of the feature sub_feature_id character_data Identifier string of the subfeature, or a zero-length string if not a subfeature sub_feature_name character_data Descriptive name of the subfeature, or a zero-length string if not a subfeature is_supported character_data YES if the feature is fully supported by the current version of PostgreSQL, NO if not is_verified_by character_data Always null, since the PostgreSQL development group does not perform formal testing of feature conformance comments character_data Possibly a comment about the supported status of the feature
<literal>sql_implementation_info</literal> The table sql_information_info contains information about various aspects that are left implementation-defined by the SQL standard. This information is primarily intended for use in the context of the ODBC interface; users of other interfaces will probably find this information to be of little use. For this reason, the individual implementation information items are not described here; you will find them in the description of the ODBC interface. <literal>sql_implementation_info</literal> Columns Name Data Type Description implementation_info_id character_data Identifier string of the implementation information item implementation_info_name character_data Descriptive name of the implementation information item integer_value cardinal_number Value of the implementation information item, or null if the value is contained in the column character_value character_value character_data Value of the implementation information item, or null if the value is contained in the column integer_value comments character_data Possibly a comment pertaining to the implementation information item
<literal>sql_languages</literal> The table sql_languages contains one row for each SQL language binding that is supported by PostgreSQL. PostgreSQL supports direct SQL and embedded SQL in C; that is all you will learn from this table. <literal>sql_languages</literal> Columns Name Data Type Description sql_language_source character_data The name of the source of the language definition; always ISO 9075, that is, the SQL standard sql_language_year character_data The year the standard referenced in sql_language_source was approved; currently 1999 sql_language_comformance character_data The standard conformance level for the language binding. For ISO 9075:1999 this is always CORE. sql_language_integrity character_data Always null (This value is relevant to an earlier version of the SQL standard.) sql_language_implementation character_data Always null sql_language_binding_style character_data The language binding style, either DIRECT or EMBEDDED sql_language_programming_language character_data The programming language, if the binding style is EMBEDDED, else null. PostgreSQL only supports the language C.
<literal>sql_packages</literal> The table sql_packages contains information about which features packages defined in the SQL standard are supported by PostgreSQL. Refer to for background information on feature packages. <literal>sql_packages</literal> Columns Name Data Type Description feature_id character_data Identifier string of the package feature_name character_data Descriptive name of the package is_supported character_data YES if the package is fully supported by the current version of PostgreSQL, NO if not is_verified_by character_data Always null, since the PostgreSQL development group does not perform formal testing of feature conformance comments character_data Possibly a comment about the supported status of the package
<literal>sql_sizing</literal> The table sql_sizing contains information about various size limits and maximum values in PostgreSQL. This information is primarily intended for use in the context of the ODBC interface; users of other interfaces will probably find this information to be of little use. For this reason, the individual sizing items are not described here; you will find them in the description of the ODBC interface. <literal>sql_sizing</literal> Columns Name Data Type Description sizing_id cardinal_number Identifier of the sizing item sizing_name character_data Descriptive name of the sizing item supported_value cardinal_number Value of the sizing item, or 0 if the size is unlimited or cannot be determined, or null if the features for which the sizing item is applicable are not supported comments character_data Possibly a comment pertaining to the sizing item
<literal>sql_sizing_profiles</literal> The table sql_sizing_profiles contains information about the sql_sizing values that are required by various profiles of the SQL standard. PostgreSQL does not track any SQL profiles, so this table is empty. <literal>sql_sizing_profiles</literal> Columns Name Data Type Description sizing_id cardinal_number Identifier of the sizing item sizing_name character_data Descriptive name of the sizing item profile_id character_data Identifier string of a profile required_value cardinal_number The value required by the SQL profile for the sizing item, or 0 if the profile places no limit on the sizing item, or null if the profile does not require any of the features for which the sizing item is applicable comments character_data Possibly a comment pertaining to the sizing item within the profile
<literal>table_constraints</literal> The view table_constraints contains all constraints belonging to tables owned by the current user. <literal>table_constraints</literal> Columns Name Data Type Description constraint_catalog sql_identifier Name of the database that contains the constraint (always the current database) constraint_schema sql_identifier Name of the schema that contains the constraint constraint_name sql_identifier Name of the constraint table_catalog sql_identifier Name of the database that contains the table (always the current database) table_schema sql_identifier Name of the schema that contains the table table_name sql_identifier Name of the table constraint_type character_data Type of the constraint: CHECK, FOREIGN KEY, PRIMARY KEY, or UNIQUE is_deferrable character_data YES if the constraint is deferrable, NO if not initially_deferred character_data YES if the constraint is deferrable and initially deferred, NO if not
<literal>table_privileges</literal> The view table_privileges identifies all privileges granted on tables or views to the current user or by the current user. There is one row for each combination of table, grantor, and grantee. Privileges granted to groups are identified in the view role_table_grants. <literal>table_privileges</literal> Columns Name Data Type Description grantor sql_identifier Name of the user that granted the privilege grantee sql_identifier Name of the user or group that the privilege was granted to table_catalog sql_identifier Name of the database that contains the table (always the current database) table_schema sql_identifier Name of the schema that contains the table table_name sql_identifier Name of the table privilege_type character_data Type of the privilege: SELECT, DELETE, INSERT, UPDATE, REFERENCES, RULE, or TRIGGER is_grantable character_data YES if the privilege is grantable, NO if not with_hierarchy character_data Applies to a feature not available in PostgreSQL
Note that the column grantee makes no distinction between users and groups. If you have users and groups with the same name, there is unfortunately no way to distinguish them. A future version of PostgreSQL will possibly prohibit having users and groups with the same name.
<literal>tables</literal> The view tables contains all tables and views defined in the current database. Only those tables and views are shown that the current user has access to (by way of being the owner or having some privilege). <literal>tables</literal> Columns Name Data Type Description table_catalog sql_identifier Name of the database that contains the table (always the current database) table_schema sql_identifier Name of the schema that contains the table table_name sql_identifier Name of the table table_type character_data Type of the table: BASE TABLE for a persistent base table (the normal table type), VIEW for a view, or LOCAL TEMPORARY for a temporary table self_referencing_column_name sql_identifier Applies to a feature not available in PostgreSQL reference_generation character_data Applies to a feature not available in PostgreSQL user_defined_type_catalog sql_identifier Applies to a feature not available in PostgreSQL user_defined_type_schema sql_identifier Applies to a feature not available in PostgreSQL user_defined_type_name sql_identifier Applies to a feature not available in PostgreSQL
<literal>triggers</literal> The view triggers contains all triggers defined in the current database that are owned by the current user. (The owner of the table is the owner of the trigger.) <literal>triggers</literal> Columns Name Data Type Description trigger_catalog sql_identifier Name of the database that contains the trigger (always the current database) trigger_schema sql_identifier Name of the schema that contains the trigger trigger_name sql_identifier Name of the trigger event_manipulation character_data Event that fires the trigger (INSERT, UPDATE, or DELETE) event_object_catalog sql_identifier Name of the database that contains the table that the trigger is defined on (always the current database) event_object_schema sql_identifier Name of the schema that contains the table that the trigger is defined on event_object_name sql_identifier Name of the table that the trigger is defined on action_order cardinal_number Not yet implemented action_condition character_data Applies to a feature not available in PostgreSQL action_statement character_data Statement that is executed by the trigger (currently always EXECUTE PROCEDURE function(...)) action_orientation character_data Identifies whether the trigger fires once for each processed row or once for each statement (ROW or STATEMENT) condition_timing character_data Time at which the trigger fires (BEFORE or AFTER) condition_reference_old_table sql_identifier Applies to a feature not available in PostgreSQL condition_reference_new_table sql_identifier Applies to a feature not available in PostgreSQL
Triggers in PostgreSQL have two incompatibilities with the SQL standard that affect the representation in the information schema. First, trigger names are local to the table in PostgreSQL, rather than independent schema objects. Therefore there may be duplicate trigger names defined in one schema, as long as they belong to different tables. (trigger_catalog and trigger_schema are really the values pertaining to the table that the trigger is defined on.) Second, triggers can be defined to fire on multiple events in PostgreSQL (e.g., ON INSERT OR UPDATE), whereas the SQL standard only allows one. If a trigger is defined to fire on multiple events, it is represented as multiple rows in the information schema, one for each type of event. As a consequence of these two issues, the primary key of the view triggers is really (trigger_catalog, trigger_schema, trigger_name, event_object_name, event_manipulation) instead of (trigger_catalog, trigger_schema, trigger_name), which is what the SQL standard specifies. Nonetheless, if you define your triggers in a manner that conforms with the SQL standard (trigger names unique in the schema and only one event type per trigger), this will not affect you.
<literal>usage_privileges</literal> The view usage_privileges is meant to identify USAGE privileges granted on various kinds of objects to the current user or by the current user. In PostgreSQL, this currently only applies to domains, and since domains do not have real privileges in PostgreSQL, this view shows implicit USAGE privileges granted to PUBLIC for all domains. In the future, this view may contain more useful information. <literal>usage_privileges</literal> Columns Name Data Type Description grantor sql_identifier Currently set to the name of the owner of the object grantee sql_identifier Currently always PUBLIC object_catalog sql_identifier Name of the database containing the object (always the current database) object_schema sql_identifier Name of the schema containing the object object_name sql_identifier Name of the object object_type character_data Currently always DOMAIN privilege_type character_data Always USAGE is_grantable character_data Currently always NO
<literal>view_column_usage</literal> The view view_column_usage identifies all columns that are used in the query expression of a view (the SELECT statement that defines the view). A column is only included if the current user is the owner of the table that contains the column. Columns of system tables are not included. This should be fixed sometime. <literal>view_column_usage</literal> Columns Name Data Type Description view_catalog sql_identifier Name of the database that contains the view (always the current database) view_schema sql_identifier Name of the schema that contains the view view_name sql_identifier Name of the view table_catalog sql_identifier Name of the database that contains the table that contains the column that is used by the view (always the current database) table_schema sql_identifier Name of the schema that contains the table that contains the column that is used by the view table_name sql_identifier Name of the table that contains the column that is used by the view column_name sql_identifier Name of the column that is used by the view
<literal>view_table_usage</literal> The view view_table_usage identifies all tables that are used in the query expression of a view (the SELECT statement that defines the view). A table is only included if the current user is the owner of that table. System tables are not included. This should be fixed sometime. <literal>view_table_usage</literal> Columns Name Data Type Description view_catalog sql_identifier Name of the database that contains the view (always the current database) view_schema sql_identifier Name of the schema that contains the view view_name sql_identifier Name of the view table_catalog sql_identifier Name of the database that contains the table the table that is used by the view (always the current database) table_schema sql_identifier Name of the schema that contains the table that is used by the view table_name sql_identifier Name of the table that is used by the view
<literal>views</literal> The view views contains all views defined in the current database. Only those views are shown that the current user has access to (by way of being the owner or having some privilege). <literal>views</literal> Columns Name Data Type Description table_catalog sql_identifier Name of the database that contains the view (always the current database) table_schema sql_identifier Name of the schema that contains the view table_name sql_identifier Name of the view view definition character_data Query expression defining the view (null if the current user is not the owner of the view) check_option character_data Applies to a feature not available in PostgreSQL is_updatable character_data Not yet implemented is_insertable_into character_data Not yet implemented