to_regnamespace()

A function translating a namespace name to an OID

to_regnamespace() is a system function for translating the name of a namespace (schema) to its OID.

to_regnamespace() was added in PostgreSQL 9.5.

Usage

to_regnamespace ( text ) → regnamespace

to_regnamespace() is equivalent to using the regnamespace object identifier type cast, but returns NULL rather than raising an ERROR if no matching namespace is found.

Change history

Examples

Basic usage example for to_regnamespace():

postgres=# SELECT to_regnamespace('public')::oid;
 to_regnamespace 
-----------------
            2200
(1 row)

NULL is returned if the specified namespace does not exist:

postgres=# SELECT to_regnamespace('foo') IS NULL;
 ?column? 
----------
 t
(1 row)

Categories

Schema (namespace), System function

See also

to_regclass()