Is it possible to set search_path to multiple schema?
Below is my test on postgres: set search_path to multiple schema.
db=# begin; set search_path to SCHEMA1,SCHEMA2;
db=# SHOW search_path;
Show search_path return SCHEMA1,SCHEMA2, but when search data, display data from one schema : SCHEMA1. Unable to find data on SCHEMA2
Thank You
My Answer:
Yes, it is possible to set the search_path to multiple schemas in PostgreSQL. However, when you set the search_path to multiple schemas, PostgreSQL will search for objects in the schemas in the order they are listed in the search_path.
In your example, if you set the search_path to SCHEMA1,SCHEMA2, PostgreSQL will first search for objects in SCHEMA1 and if it does not find the object there, it will then search in SCHEMA2.
If you are unable to find data in SCHEMA2 even after setting the search_path, it could be due to the data not being present in that schema or there could be some other issue. I would recommend checking the data in SCHEMA2 to ensure it is present and accessible.
Rate this post
4 of 5 based on 1367 votesComments