Set Schema Search Path

Each user session has a search path of schemas. YugabyteDB uses this search path to find tables, views, stored procedures, etc. that are unqualified by their schema name.

You can change the session’s search path at any time by calling SET SEARCH_PATH. This search path remains in effect until the next SET SEARCH_PATH statement, or the session ends.

Example:

				
					
yugabyte=# CREATE SCHEMA s1;
CREATE SCHEMA

yugabyte=# CREATE SCHEMA s2;
CREATE SCHEMA

yugabyte=# CREATE TABLE s1.t (c INT);
CREATE TABLE

yugabyte=# CREATE TABLE s2.t (c INT);
CREATE TABLE

yugabyte=# INSERT INTO s1.t VALUES (1), (2), (3);
INSERT 0 3

yugabyte=# INSERT INTO s2.t VALUES (4), (5), (6);
INSERT 0 3

yugabyte=# SHOW search_Path;
   search_path
-----------------
 "$user", public
(1 row)

yugabyte=# SET search_path = "$user", public, s1;
SET

yugabyte=# SELECT * FROM t;
 c
---
 1
 3
 2
(3 rows)

yugabyte=# SET search_path = "$user", public, s2;
SET

yugabyte=# SELECT * FROM t;
 c
---
 4
 5
 6
(3 rows)
				
			

Have Fun!