I'm reading Oreilly's PostgreSQL: Up and Running, and in the section Organizing Your Database Using Schemas it says the search_path may be set at the database level:

For example, if we wanted all objects in contrib to be accessible without schema qualification, we would change our database as follows:

ALTER DATABASE mydb SET search_path="$user",public,contrib;

However, after typing the command above, I still can't refer to tables in schemas other then public without qualifying them:

ALTER DATABASE auth SET search_path="$user",public,staging;`
\d users


Did not find any relation named "users".

But if I use \d staging.users, it works.

SHOW search_path;



Does the default search_path from postgresql.conf override the per-database value set with ALTER DATABASE ... SET search_path ? If that's the case, what's the use of the per-database value?

  • can you select * from users? Aug 10, 2012 at 18:32
  • No, I can't select * from users but I can select * from staging.users. Aug 10, 2012 at 18:41
  • 4
    Did you reconnect to your database after setting a new default for its search_path? Did you try just setting the search_path for your connection?
    – kgrittn
    Aug 10, 2012 at 18:46
  • I hadn't reconnected yet. Reconnecting psql solved my problem, thanks. Would you write an answer so I can mark it as accepted? Aug 10, 2012 at 19:39
  • 1
    @Daniel, it's not a syntax error in MySQL (" vs '). Single and double quotes are treated the same (unless it's set on ANSI SQL mode). (Commenting here as you wouldn't see it there. I'll delete this comment later) Jan 29, 2018 at 23:55

1 Answer 1


The citation from the SET related paragraph of the ALTER DATABASE documentation section is "Whenever a new session is subsequently started in that database, the specified value becomes the session default value". So the changes will take effect for new sessions only. You just need to reconnect.

  • Without reconnecting, to modify search_path on the current session (in your psql session, for example) you can use SET search_path TO "$user",public,contrib;.
    – Matt
    May 14, 2016 at 14:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.