Grokbase
Topics Posts Groups | in
x
[ help ]

Schema search_path and views

View PostFlat  Thread  Threaded | Next >
Just Someone Schema search_path and views
| +1 vote
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
I have a database with multiple schemas all with the same structure
(but of course different data...).

I want to create a view that will be created in a shared schema, and
when executed will be executed against the current schema. Whenever I
try it, it seems the view is linked to a specific schema used when
creating it, and doesn't reevaluates based on the current schema.

Here is the pseudo structure/code:

schema1:
=======
create table t1 ...

schema2:
=======
create table t1 ...

shared_schema:
============
create table t3 ...

create the view:
===========
set search_path to shared_schema, schema1;
create view view1 as select * from t1;

try the view:
========
set search_path to shared_schema, schema1;
select * from view1;
set search_path to shared_schema, schema2;
select * from view1;

Results:
======
In the above, both select * from view1; will return the same data,
though the search path changed.

Is there a way to make the view use the current search_path?



--
Family management on rails: http://www.famundo.com - coming soon!
My development related blog: http://devblog.famundo.com

Thread : Schema search_path and views
1)
Just Someone I have a database with multiple schemas all with the same structure I want to create a view that...
2)
Just Someone Cool! That explains it fully. So i guess there will be a better performance to the pre-generated...
3)
William Leite Araújo 2006/11/6, Just Someone <just.some@gmail.com>: In this point, your view was created with thi code:...
4)
Merlin Moncure no, or not exactly. views resolve the search path when they are generated. this is a fundemental...
spacer
View PostFlat  Thread  Threaded | Next >