我想獲取我當前的連接模式名稱,我發現 '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
我需要使用 table_schema = show search_path
uj5u.com熱心網友回復:
SELECT EXISTS (
SELECT 1 FROM information_schema.tables
WHERE table_name = 'project_customer_scheme'
AND table_schema = (
SELECT setting FROM pg_settings WHERE name = 'search_path'
)
uj5u.com熱心網友回復:
使用該current_schema功能。它為您提供了search_path實際存在的第一個模式,即將創建不合格表的模式。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/348641.html
上一篇:如何從查詢中洗掉DISTINCT,在Postgresql
下一篇:為專案生成帶有測驗資料的多行
