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?
In order to set the default schema for a Windows Group, open SQL Server Management Studio, navigate to Security > Logins, right click on the Windows Group that you want to change and choose Properties.
In the Database Administration view upper pane, select the database. Right-click the database and select Set default schema. The Set default schema dialog appears.
How can you tell the name of the current default schema? SELECT SCHEMA_NAME(); The SCHEMA_NAME() function will return the name of a schema if you pass it the schema_id but if you don't pass anything, it will return the name of the current default schema.
SET search_path TO inventory, public; Now inventory is a default schema and you don't need to mention it explicitly to access it. You can change the name or the ownership of a schema by using ALTER SCHEMA. DROP SCHEMA [IF EXISTS] schema_name [CASCADE | RESTRICT];
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With