MySQL Forums
Forum List  »  Security

Re: Row-level security in MySQL?
Posted by: Bill Karwin
Date: August 07, 2006 11:43PM

The equivalent is to define a view restricted to a subset of rows, and let a user query the view, even though she does not have privilege to query the base table.

USE test;

CREATE TABLE `foo` (
  `i` int(11) default NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

INSERT INTO `foo` (i) VALUES (10), (20);

CREATE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `foo_v` 
  AS select `foo`.`i` AS `i` from `foo` where (`foo`.`i` < 15)';

GRANT ALL on test.foo_v TO 'bill'@'localhost' identified by 'password';

Then log in to the test database as 'bill', and notice that the view `foo_v` is visible, but the table `foo` is not. Querying `foo_v` shows only that which is shown by the view.

Options: ReplyQuote


Subject
Views
Written By
Posted
7157
August 04, 2006 06:43AM
Re: Row-level security in MySQL?
4645
August 07, 2006 11:43PM
3620
October 09, 2006 09:00AM


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.