gotchasqlMinor
What is the difference between "ALTER DATABASE mydb SET search_path" and "SET search_path"?
Viewed 0 times
thewhatdatabasedifferencebetweensearch_pathmydbandalterset
Problem
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.
Solution
ALTER DATABASE will change the search_path for every new connection to that database. The change however does not affect current connections - including the one that ran the ALTER DATABASE. The set search_path then changes the path also for the current connection so that it has the same value as the default path.Context
StackExchange Database Administrators Q#186686, answer score: 7
Revisions (0)
No revisions yet.