Re: How to limit access only to certain records?

From: hari(dot)fuchs(at)gmail(dot)com
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: How to limit access only to certain records?
Date: 2012-06-22 14:52:35
Message-ID: 87r4t78klo.fsf@hf.protecting.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Andreas <maps(dot)on(at)gmx(dot)net> writes:

> Hi,
>
> is there a way to limit access for some users only to certain records?
>
> e.g. there is a customer table and there are account-managers.
> Could I limit account-manager #1 so that he only can access customers
> only acording to a flag?

Maybe something like the following:

CREATE TABLE test1 (
id serial NOT NULL,
val text NOT NULL,
_user text NOT NULL,
PRIMARY KEY (id)
);

COPY test1 (val, _user) FROM stdin;
for user1#1 user1
for user1#2 user1
for user2#1 user2
\.

CREATE VIEW test1v AS
SELECT id, val
FROM test1
WHERE _user = current_user;

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Craig Ringer 2012-06-24 06:58:28 Re: How to limit access only to certain records?
Previous Message Jayadevan M 2012-06-22 13:03:25 Re: How to limit access only to certain records?