postgresql 更改用户的默认架构
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/44429178/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Change default schema for user
提问by Oto Shavadze
create schema bla;
-- then create table table_name into this schema
Then I want change default schema for user (user is postgres
)
然后我想更改用户的默认架构(用户是postgres
)
I do: ALTER ROLE postgres SET search_path TO bla;
(Query returned successfully with no result).
我这样做:( ALTER ROLE postgres SET search_path TO bla;
查询成功返回,没有结果)。
When I try SELECT * FROM table_name
gives error relation "table_name" does not exist
当我尝试SELECT * FROM table_name
给出错误时relation "table_name" does not exist
Though SELECT * FROM bla.table_name
works fine.
虽然SELECT * FROM bla.table_name
工作正常。
What is wrong in my attempt to change default schema for user?
我尝试更改用户的默认架构有什么问题?
回答by Vao Tsun
I think you need to relogin for that. With ALTER USER ... SET
you change
我认为您需要为此重新登录。随ALTER USER ... SET
你而变
Session defaults for run-time configuration variables
运行时配置变量的会话默认值
Also from ALTER ROLE SET
manual:
也来自ALTER ROLE SET
手册:
Role-specific variable settings take effect only at login;
特定于角色的变量设置仅在登录时生效;
But don't apply changes to current session. If you want immediate change use:
但不要将更改应用于当前会话。如果您想立即更改使用:
SET search_path TO bla;
It will change path on session level
它将在会话级别更改路径