pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Huxton <dev@archonet.com>
To: Din Adrian <adrian.din@easynet.ro>
Cc: pgsql-sql@postgresql.org
Subject: Re: private table
Date: Wed, 26 Jan 2005 08:55:43 +0000
Message-ID: <41F75B0F.6030504@archonet.com> (raw)
In-Reply-To: <opsk7aheyzawcxfg@adi>
References: <opsk7aheyzawcxfg@adi>

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



view thread (3+ messages)

Message-ID: <41F75B0F.6030504@archonet.com>
Permalink:  ../41F75B0F.6030504@archonet.com/
Also on:    postgresql.org/message-id/41F75B0F.6030504@archonet.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: dev@archonet.com, adrian.din@easynet.ro
  Subject: Re: private table
  In-Reply-To: <41F75B0F.6030504@archonet.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox