PostgreSQL 9.6. I just found both of these commands in a flyway migration, right next to each other. I feel like they are probably redundant but how do these statements differ? Is there a reason to use both? Apologies if this is a duplicate; I couldn't find an answer.
PostgreSQL – Difference Between ALTER DATABASE SET search_path and SET search_path
postgresql
Related Question
- PostgreSQL – List Chronological Pageviews Without Adjacent Duplicates
- Postgresql – How to perform schema migration from array to many-to-many to lookup table
- PostgreSQL – How to Swap Primary Key Between Records
- Postgresql – What makes it so much faster to write to the “WAL” compared to directly to the “real database”
- PostgreSQL Performance – JSONB_Set Performance in PostgreSQL
Best Answer
ALTER DATABASE
will change thesearch_path
for every new connection to that database. The change however does not affect current connections - including the one that ran theALTER DATABASE
. Theset search_path
then changes the path also for the current connection so that it has the same value as the default path.