I'm the process of moving applications over from all in the public schema to each having their own schema. for each application, I have a small script that will create the schema and then create the tables,functions,etc... to that schema. Is there anyway to automatically add a newly created schema to the search_path? Currently, the only way I see is to find the users current path SHOW search_path;
and then add the new schema to it SET search_path to xxx,yyy,zzz;
I would like some way to just say, append schema zzz to the users_search path. is this possible?
The default search path makes PostgreSQL search first in the schema named exactly as the user name you used for logging into the database. If the user name is different from the schema names, or there is no table szymon. a then it would look in the public.
The phpPgAdmin administration page appears in a new window. In the left pane of the phpPgAdmin window, expand Servers, expand PostgreSQL, and then click the name of the database that you want to import the data into. On the top menu bar, click SQL. The SQL link is located between the Schemas and Find links.
Use the set_config()
function like so:
SELECT set_config(
'search_path',
current_setting('search_path') || ',zzz',
false
) WHERE current_setting('search_path') !~ '(^|,)zzz(,|$)';
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