PostgreSQL The Information Schema

I want to learn more about the "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 modeled after implementation concerns.

Date Created:
1 40

References



Notes


The information schema consists of a set of views that contain information about the objects defined in the current databased. 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 modeled after implementation concerns. The information schema views do not, however, contain information about PostgreSQL specific features.

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.

The columns of the information schema view use special data that are defined in the information schema. These are defined as simple domains over ordinary built in types. You should not use these types outside of the information schema, but you should use them if they select from the information schema.

The information_schema_catalog_name is a table that always contains one row and one column containing the name of the current database. The administratable_role_authorization identifies all roles that the current user has the admin option for. The view applicable_roles identifies all roles whose privileges the current user can use. This means there is some chain of role grants from the current user to the role in question.

The view attributes contains information about the attributes of composite data types defines in the database. Only those attributes are shown that the current user has access to. The view check_constraint_routine_usage identifies routines that are used by a check constraint. The view check_constraints contains all check constraints, either defined in a table or a domain, that are owned by a currently enabled role. The view collations contains the collations available in the current database. The view column_column_usage identifies all generated columns that depend on another base column in the same table. Only tables owned by a currently enabled role are included. The view column_options contains all the options defined for foreign table columns in the current database. Only those foreign table columns are shown that the current user has access to. The view column_priveleges identifies all privileges granted on columns to a currently enabled role or by a currently enabled role.

The view columns contains information about all table columns (or view columns) in the database. System columns are not included. Only those columns are shown that the current user has access to. The view constaint_column_usage identifies all columns in the current database that are used by some constraint. The view constraint_table_usage identifies all tables in the current database that are used by some constraint and are owned by a currently enabled role. 

You can read more about how comments are sorted in this blog post.

User Comments

Insert Math Markup

ESC
About Inserting Math Content
Display Style:

Embed News Content

ESC
About Embedding News Content

Embed Youtube Video

ESC
Embedding Youtube Videos

Embed TikTok Video

ESC
Embedding TikTok Videos

Embed X Post

ESC
Embedding X Posts

Embed Instagram Post

ESC
Embedding Instagram Posts

Insert Details Element

ESC

Example Output:

Summary Title
You will be able to insert content here after confirming the title of the <details> element.

Insert Table

ESC
Customization
Align:
Preview:

Insert Horizontal Rule

#000000

Preview:


View Content At Different Sizes

ESC

Edit Style of Block Nodes

ESC

Edit the background color, default text color, margin, padding, and border of block nodes. Editable block nodes include paragraphs, headers, and lists.

#ffffff
#000000

Edit Selected Cells

Change the background color, vertical align, and borders of the cells in the current selection.

#ffffff
Vertical Align:
Border
#000000
Border Style:

Edit Table

ESC
Customization:
Align:

Upload Files

ESC

Upload a .lexical file. If the file type matches the type of the current editor, then a preview will be shown below the file input.

Upload Jupyter Notebook

ESC

Upload a Jupyter notebook and embed the resulting HTML in the text editor.

Insert Custom HTML

ESC

Edit Image

ESC
#ffffff

Insert Columns Layout

ESC
Column Type:

Select Code Language

ESC
Select Coding Language

Upload Previous Version of Editor State

ESC