问题
create schema bla;
-- then create table table_name into this schema
Then I want change default schema for user (user is postgres)
I do: ALTER ROLE postgres SET search_path TO bla; (Query returned successfully with no result).
When I try SELECT * FROM table_name gives error relation "table_name" does not exist
Though SELECT * FROM bla.table_name works fine.
What is wrong in my attempt to change default schema for user?
回答1:
I think you need to relogin for that. With ALTER USER ... SET you change
Session defaults for run-time configuration variables
Also from ALTER ROLE SET manual:
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
来源:https://stackoverflow.com/questions/44429178/change-default-schema-for-user