I am do ing a search on a post gres table and getting no records returned. The matching records are in the table I am searching. There is another table in aother schema where the data is not in any record. I set the schema search path =, howeve I do not know how to check what the current one is.
How do I determne the current schem search path?
Get the current schema search path in a postgress DB.
2
Answers
execute the following SQL query to determine the current schema search path in a PostgresDB:
The
current_schemas()
session information function can give you the full context:Better yet, you can ask directly whether the table you think is visible, is in fact visible to you, using the
pg_table_is_visible()
function:demo at db<>fiddle
set search_path=another_schema
will only affect the one session it happened to execute in. If you’re sending statements straight to the pool, the setting change and the query expecting the setting changed might end up in different connections.autocommit
mode that’s default for most client apps/libs, if the setting’s changed usingset local search_path=schema1;
orset_config('search_path', 'schema1', true)
, you’ll never see its effect because the transaction it was supposed to apply to, is finished immediately.alter
the setting onsystem
,database
orrole
level, it becomes the new default and does not affect any ongoing session, including the one that issued the command.role
-level default overridesdatabase
andsystem
-level defaults.