Re: private table

From: Richard Huxton <dev(at)archonet(dot)com>
To: Din Adrian <adrian(dot)din(at)easynet(dot)ro>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: private table
Date: 2005-01-26 08:55:43
Message-ID: 41F75B0F.6030504@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Din Adrian wrote:
> Hello,
> I am want to use a private table in postgresql(every client to see his
> own data).
> Is this possible? How can I do it!

If I understand what you want, then this is traditionally done using views.

CREATE TABLE base_table (
a integer NOT NULL,
b text,
u name,
PRIMARY KEY (a)
);

CREATE VIEW my_rows AS
SELECT a,b FROM base_table WHERE u = CURRENT_USER;

Add rules so that updating my_rows updates base_table instead. Then,
revoke access on base_table (apart from your super-user) but grant it on
my_rows.

As far as a user is concerned "my_rows" just contains their rows and if
they log in as a different user they will see different data.
--
Richard Huxton
Archonet Ltd

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Martin Schäfer 2005-01-26 09:10:43 Re: How to find out programmatically whether a query on a view will use an index?
Previous Message Richard Huxton 2005-01-26 08:50:21 Re: Sorry I see my first question did not get posted (maybe