0

I want user to see only a particular row in sql table eg. if i have a table with 2 user if user 1 , writes

select * top1 from emp_id 

the result must be 1st row.. but if 2nd user uses the same the answer should be 2nd row

Saghir A. Khatri
  • 3,341
  • 6
  • 40
  • 73
  • Read up on the LIMIT option in SQL statements – shrmn Apr 14 '14 at 05:28
  • @shrmn : i dont think oracle offers `limit`, thats in `mysql`... – NoobEditor Apr 14 '14 at 05:30
  • is it like your table has userid column to track if users can view rows corresponding to their ID's only? – Deepshikha Apr 14 '14 at 05:30
  • 1
    Oops, didn't notice the Oracle tag. Sorry. In that case, maybe an equivalent of the LIMIT function? http://stackoverflow.com/questions/470542/how-do-i-limit-the-number-of-rows-returned-by-an-oracle-query-after-ordering – shrmn Apr 14 '14 at 05:33
  • Is what you want row-level security? http://docs.oracle.com/cd/E38689_01/pt853pbr0/eng/pt/tsec/task_DefiningRow-LevelSecurityandQuerySecurityRecords-c077b2.html – RobP Apr 14 '14 at 05:36
  • In Oracle 12c they introduced the `FETCH FIRST` clause which provides the same function like `LIMIT` on MySql. – Wernfried Domscheit Apr 14 '14 at 07:12

1 Answers1

0

You can create a view on emp_id table as below and provide select grant on the view (instead of providing grant on the table) to the user.

create or replace view v_emp_id as select * from emp_id where user_name=user;

So the users can see their own data....

Krishna
  • 451
  • 2
  • 6