pg_namespace

A system table containing schema definitions

pg_namespace is a system catalogue table containing schema definitions.

pg_namespace was introduced in PostgreSQL 7.3.

psql commands

  • \dn lists the available schemas

Definition by PostgreSQL version

pg_namespace (PostgreSQL 15)

            Table "pg_catalog.pg_namespace"
  Column  |   Type    | Collation | Nullable | Default 
----------+-----------+-----------+----------+---------
 oid      | oid       |           | not null | 
 nspname  | name      |           | not null | 
 nspowner | oid       |           | not null | 
 nspacl   | aclitem[] |           |          | 
Indexes:
    "pg_namespace_oid_index" PRIMARY KEY, btree (oid)
    "pg_namespace_nspname_index" UNIQUE CONSTRAINT, btree (nspname)
    

Documentation: pg_namespace

pg_namespace (PostgreSQL 14)

            Table "pg_catalog.pg_namespace"
  Column  |   Type    | Collation | Nullable | Default 
----------+-----------+-----------+----------+---------
 oid      | oid       |           | not null | 
 nspname  | name      |           | not null | 
 nspowner | oid       |           | not null | 
 nspacl   | aclitem[] |           |          | 
Indexes:
    "pg_namespace_oid_index" PRIMARY KEY, btree (oid)
    "pg_namespace_nspname_index" UNIQUE CONSTRAINT, btree (nspname)
    

Documentation: pg_namespace

pg_namespace (PostgreSQL 13)

            Table "pg_catalog.pg_namespace"
  Column  |   Type    | Collation | Nullable | Default 
----------+-----------+-----------+----------+---------
 oid      | oid       |           | not null | 
 nspname  | name      |           | not null | 
 nspowner | oid       |           | not null | 
 nspacl   | aclitem[] |           |          | 
Indexes:
    "pg_namespace_nspname_index" UNIQUE, btree (nspname)
    "pg_namespace_oid_index" UNIQUE, btree (oid)
    

Documentation: pg_namespace

pg_namespace (PostgreSQL 12)

            Table "pg_catalog.pg_namespace"
  Column  |   Type    | Collation | Nullable | Default 
----------+-----------+-----------+----------+---------
 oid      | oid       |           | not null | 
 nspname  | name      |           | not null | 
 nspowner | oid       |           | not null | 
 nspacl   | aclitem[] |           |          | 
Indexes:
    "pg_namespace_nspname_index" UNIQUE, btree (nspname)
    "pg_namespace_oid_index" UNIQUE, btree (oid)
    

Documentation: pg_namespace

pg_namespace (PostgreSQL 11)

            Table "pg_catalog.pg_namespace"
  Column  |   Type    | Collation | Nullable | Default 
----------+-----------+-----------+----------+---------
 nspname  | name      |           | not null | 
 nspowner | oid       |           | not null | 
 nspacl   | aclitem[] |           |          | 
Indexes:
    "pg_namespace_nspname_index" UNIQUE, btree (nspname)
    "pg_namespace_oid_index" UNIQUE, btree (oid)
    

Documentation: pg_namespace

pg_namespace (PostgreSQL 10)

            Table "pg_catalog.pg_namespace"
  Column  |   Type    | Collation | Nullable | Default 
----------+-----------+-----------+----------+---------
 nspname  | name      |           | not null | 
 nspowner | oid       |           | not null | 
 nspacl   | aclitem[] |           |          | 
Indexes:
    "pg_namespace_nspname_index" UNIQUE, btree (nspname)
    "pg_namespace_oid_index" UNIQUE, btree (oid)
    

Documentation: pg_namespace

pg_namespace (PostgreSQL 9.6)

 Table "pg_catalog.pg_namespace"
  Column  |   Type    | Modifiers 
----------+-----------+-----------
 nspname  | name      | not null
 nspowner | oid       | not null
 nspacl   | aclitem[] | 
Indexes:
    "pg_namespace_nspname_index" UNIQUE, btree (nspname)
    "pg_namespace_oid_index" UNIQUE, btree (oid)
    

Documentation: pg_namespace

pg_namespace (PostgreSQL 9.5)

 Table "pg_catalog.pg_namespace"
  Column  |   Type    | Modifiers 
----------+-----------+-----------
 nspname  | name      | not null
 nspowner | oid       | not null
 nspacl   | aclitem[] | 
Indexes:
    "pg_namespace_nspname_index" UNIQUE, btree (nspname)
    "pg_namespace_oid_index" UNIQUE, btree (oid)
    

Documentation: pg_namespace

pg_namespace (PostgreSQL 9.4)

 Table "pg_catalog.pg_namespace"
  Column  |   Type    | Modifiers 
----------+-----------+-----------
 nspname  | name      | not null
 nspowner | oid       | not null
 nspacl   | aclitem[] | 
Indexes:
    "pg_namespace_nspname_index" UNIQUE, btree (nspname)
    "pg_namespace_oid_index" UNIQUE, btree (oid)
    

Documentation: pg_namespace

pg_namespace (PostgreSQL 9.3)

 Table "pg_catalog.pg_namespace"
  Column  |   Type    | Modifiers 
----------+-----------+-----------
 nspname  | name      | not null
 nspowner | oid       | not null
 nspacl   | aclitem[] | 
Indexes:
    "pg_namespace_nspname_index" UNIQUE, btree (nspname)
    "pg_namespace_oid_index" UNIQUE, btree (oid)
    

Documentation: pg_namespace

pg_namespace (PostgreSQL 9.2)

 Table "pg_catalog.pg_namespace"
  Column  |   Type    | Modifiers 
----------+-----------+-----------
 nspname  | name      | not null
 nspowner | oid       | not null
 nspacl   | aclitem[] | 
Indexes:
    "pg_namespace_nspname_index" UNIQUE, btree (nspname)
    "pg_namespace_oid_index" UNIQUE, btree (oid)
    

Documentation: pg_namespace

pg_namespace (PostgreSQL 9.1)

 Table "pg_catalog.pg_namespace"
  Column  |   Type    | Modifiers 
----------+-----------+-----------
 nspname  | name      | not null
 nspowner | oid       | not null
 nspacl   | aclitem[] | 
Indexes:
    "pg_namespace_nspname_index" UNIQUE, btree (nspname)
    "pg_namespace_oid_index" UNIQUE, btree (oid)
    

Documentation: pg_namespace

pg_namespace (PostgreSQL 9.0)

 Table "pg_catalog.pg_namespace"
  Column  |   Type    | Modifiers 
----------+-----------+-----------
 nspname  | name      | not null
 nspowner | oid       | not null
 nspacl   | aclitem[] | 
Indexes:
    "pg_namespace_nspname_index" UNIQUE, btree (nspname)
    "pg_namespace_oid_index" UNIQUE, btree (oid)
    

Documentation: pg_namespace

pg_namespace (PostgreSQL 8.4)

 Table "pg_catalog.pg_namespace"
  Column  |   Type    | Modifiers 
----------+-----------+-----------
 nspname  | name      | not null
 nspowner | oid       | not null
 nspacl   | aclitem[] | 
Indexes:
    "pg_namespace_nspname_index" UNIQUE, btree (nspname)
    "pg_namespace_oid_index" UNIQUE, btree (oid)
    

Documentation: pg_namespace

pg_namespace (PostgreSQL 8.3)

 Table "pg_catalog.pg_namespace"
  Column  |   Type    | Modifiers 
----------+-----------+-----------
 nspname  | name      | not null
 nspowner | oid       | not null
 nspacl   | aclitem[] | 
Indexes:
    "pg_namespace_nspname_index" UNIQUE, btree (nspname)
    "pg_namespace_oid_index" UNIQUE, btree (oid)
    

Documentation: pg_namespace

pg_namespace (PostgreSQL 8.2)

 Table "pg_catalog.pg_namespace"
  Column  |   Type    | Modifiers 
----------+-----------+-----------
 nspname  | name      | not null
 nspowner | oid       | not null
 nspacl   | aclitem[] | 
Indexes:
    "pg_namespace_nspname_index" UNIQUE, btree (nspname)
    "pg_namespace_oid_index" UNIQUE, btree (oid)
    

Documentation: pg_namespace

Change history

This table has not been modified since it was added in PostgreSQL 7.3.

Examples

postgres=# CREATE SCHEMA someschema;
CREATE SCHEMA
postgres=# \dn List of schemas Name | Owner ------------+---------- public | postgres someschema | postgres (2 rows) postgres=# SELECT * FROM pg_namespace; nspname | nspowner | nspacl --------------------+----------+------------------------------------- pg_toast | 10 | pg_temp_1 | 10 | pg_toast_temp_1 | 10 | pg_catalog | 10 | {postgres=UC/postgres,=U/postgres} public | 10 | {postgres=UC/postgres,=UC/postgres} information_schema | 10 | {postgres=UC/postgres,=U/postgres} someschema | 10 | (7 rows)

Categories

Schema (namespace), System catalogue

See also

CREATE SCHEMA, ALTER SCHEMA, DROP SCHEMA, pg_default_acl