Postgres 获取当前模式名称

san*_*dev 3 postgresql plpgsql

我想获取当前的连接架构名称,我发现“show search_path”返回所需的结果,但我需要在查询中使用此结果。

如何在 Postgres 查询中使用“show search_path”?

if not (SELECT EXISTS (SELECT 1 FROM information_schema.tables WHERE 
  table_name = 'customer' and table_schema = **show search_path** )) then
do something ....
end
Run Code Online (Sandbox Code Playgroud)

我需要使用 table_schema = show search_path

Lau*_*lbe 8

使用该current_schema功能。它为您提供了实际存在的第一个模式search_path,即将创建不合格表的模式。