Within our database we've customers: A, B, C.
Each user features its own corresponding schema: A, B, C.
Normally basically desired to choose from the table within the schemas I would need to do:
select * from A.table;
My real question is:
It is possible to method to make:
select * from table
visit the correct schema in line with the user that's drenched in?
This is actually the default behavior for PostgreSQL. Make certain your
search_path is placed properly.
Automatically it ought to be:
search_path -------------- "$user",public
See PostgreSQL's documentation on schemas to learn more. Particularly this part:
You may create a schema for every user with similar title as that user. Recall the default search path begins with $user, which resolves towards the user title. Therefore, if each user includes a separate schema, they access their very own schemas automatically.
If you are using this setup then you could also wish to revoke accessibility public schema (or drop it altogether), so customers are truly restricted to their personal schemas.
Update RE you comment: Here's what happens on my small machine. That is things i believe you're wanting.
skrall=# \d No relations found. skrall=# show search_path; search_path ---------------- "$user",public (1 row) skrall=# create schema skrall; CREATE SCHEMA skrall=# create table test(id serial); NOTICE: CREATE TABLE will create implicit sequence "test_id_seq" for serial column "test.id" CREATE TABLE skrall=# \d List of relations Schema | Name | Type | Owner --------+-------------+----------+-------- skrall | test | table | skrall skrall | test_id_seq | sequence | skrall (2 rows) skrall=# select * from test; id ---- (0 rows) skrall=#