search_path

Values (Default in Bold)

'$user', public, schema_names

A comma-separated list of existing schema names. If '$user' is present, then the schema having the same name as SESSION_USER is substituted, otherwise it is ignored. If public is present and no schema with the name public exists, it is ignored.

Description

This parameter specifies the order in which schemas are searched when an object (such as a table or a function) is referenced by a simple name with no schema component.

Example

The following example creates the schema ENTERPRISE and sets the search_path to the new schema.

create schema enterprise; set search_path to enterprise; show search_path; search_path ------------- enterprise (1 row)

The following example adds the schema ENTERPRISE to the default search_path.

set search_path to '$user', public, enterprise; show search_path; search_path ----------------------------- "$user", public, enterprise (1 row)

The following example adds the table FRONTIER to the schema ENTERPRISE:

create table enterprise.frontier (c1 int);

When the table PUBLIC.FRONTIER is created in the same database, and the user does not specify the schema name in a query, PUBLIC.FRONTIER takes precedence over ENTERPRISE.FRONTIER:.

create table public.frontier(c1 int); insert into enterprise.frontier values(1); select * from frontier; frontier ---- (0 rows) select * from enterprise.frontier; c1 ---- 1 (1 row)