Schema - update search_path

Started by Alvinover 19 years ago2 messagesgeneral
Jump to latest
#1Alvin
dartmissile@yahoo.com

Hey guys,

I would like to know a good way of updating or appending the schema names in the search path, Right now I do a show search_path, get the names of all the schemas, and then set search path; adding the new schema.

I'm in the process of integrating a few systems and will need to continuously add new schemas. The manual method above is pretty tiring and prone to errors and all that.

Looking through the mailing list I see that this question has been asked before but I don't see an answer.

Thanks.

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Alvin (#1)
Re: Schema - update search_path

Alvin <dartmissile@yahoo.com> writes:

Hey guys, I would like to know a good way of updating or appending th=
e schema names in the search path,

Perhaps like this:

regression=# create schema news;
CREATE SCHEMA
regression=# show search_path;
search_path
----------------
"$user",public
(1 row)

regression=# select set_config('search_path', current_setting('search_path') || ',' || quote_ident('news'), false);
set_config
---------------------
"$user",public,news
(1 row)

regression=# show search_path;
search_path
---------------------
"$user",public,news
(1 row)

regression=#

You should read these two pages for several useful functions:
http://www.postgresql.org/docs/8.1/static/functions-info.html
http://www.postgresql.org/docs/8.1/static/functions-admin.html

regards, tom lane