Text Size: Normal / Large

Chapter 3. System Catalogs

3.1. Overview

The system catalogs are the place where a relational database management system stores schema metadata, such as information about tables and columns, and internal bookkeeping information. PostgreSQL's system catalogs are regular tables. You can drop and recreate the tables, add columns, insert and update values, and severely mess up your system that way. Normally one should not change the system catalogs by hand, there are always SQL commands to do that. (For example, CREATE DATABASE inserts a row into the pg_database catalog -- and actually creates the database on disk.) There are some exceptions for especially esoteric operations, such as adding index access methods.

Most system catalogs are copied from the template database during database creation, and are thereafter database-specific. A few catalogs are physically shared across all databases in an installation; these are marked in the descriptions of the individual catalogs.

Table 3-1. System Catalogs

Catalog NamePurpose
pg_aggregateaggregate functions
pg_amindex access methods
pg_amopaccess method operators
pg_amprocaccess method support procedures
pg_attrdefcolumn default values
pg_attributetable columns ("attributes", "fields")
pg_castcasts (data type conversions)
pg_classtables, indexes, sequences ("relations")
pg_constraintcheck constraints, unique / primary key constraints, foreign key constraints
pg_conversionencoding conversion information
pg_databasedatabases within this database cluster
pg_dependdependencies between database objects
pg_descriptiondescriptions or comments on database objects
pg_groupgroups of database users
pg_indexadditional index information
pg_inheritstable inheritance hierarchy
pg_languagelanguages for writing functions
pg_largeobjectlarge objects
pg_listenerasynchronous notification
pg_namespacenamespaces (schemas)
pg_opclassindex access method operator classes
pg_operatoroperators
pg_procfunctions and procedures
pg_rewritequery rewriter rules
pg_shadowdatabase users
pg_statisticoptimizer statistics
pg_triggertriggers
pg_typedata types

More detailed documentation of each catalog follows below.


User Comments


Piotr Kuczynski <pkuczynski@wi.ps.pl>
17 Dec 2002 21:27:25

Here is s simple solution for finding the size of varchar's type column:


SELECT pg_class.relname, pg_attribute.attname, pg_type.typname,
pg_attribute.atttypmod-4
FROM pg_class, pg_attribute, pg_type
WHERE pg_attribute.attrelid = pg_class.oid
AND pg_attribute.atttypid = pg_type.oid
AND pg_class.relname = 'TABLE_NAME'
AND pg_attribute.attname = 'COLUMN_NAME'


Result:
.relname...|...attname...|.typname.|.atttypmod.
-----------+-------------+---------+-----------
TABLE_NAME | COLUMN_NAME | varchar | SIZE
(1 row)


Remeber that you have to decrease the value of the filed pg_attribute.atttypmod by 4, because all variable-length types begin with a length field of exactly 4 bytes.

Add Comment

Please use this form to add your own comments regarding your experience with particular features of PostgreSQL, clarifications of the documentation, or hints for other users. Please note, this is not a support forum, and your IP address will be logged. If you have a question or need help, please see the faq, try a mailing list, or join us on IRC. Note that submissions containing URLs or other keywords commonly found in 'spam' comments may be silently discarded. Please contact the webmaster if you think this is happening to you in error.

In order to submit a comment, you must have a community account.

* Comment
 

* denotes required field

Privacy Policy | Project hosted by hub.org | Designed by tinysofa
Copyright © 1996 – 2007 PostgreSQL Global Development Group