MySQL Forums
Forum List  »  Security

Re: Row level security
Posted by: Alexander Keremidarski
Date: December 07, 2005 12:19AM

Martin King-Turner wrote:
> Is it possible to restrict access to rows in a
> table, based on data contained in the row?

This is one of main reasons for VIEWS to exist.

> let's say I have just 2 columns - userid and
> message. I would like to setup the security so
> that when a particular user tries to access the
> table (even with a SELECT * query), they will be
> able to see *only* those rows where the value of
> the data in the userid column is equal to their
> MySQL login.

You create VIEW for each user and give him access to this VIEW only and not to the base table.

CREATE VIEW v_user123 AS (SELECT * FROM tbl WHERE userid=123);

Options: ReplyQuote


Subject
Views
Written By
Posted
15468
December 01, 2005 08:27AM
Re: Row level security
6692
December 07, 2005 12:19AM
6352
March 25, 2006 11:43PM
5482
March 15, 2006 06:39AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.