Improve company productivity with a Business Account.Sign Up

x
?
Solved

table level privileges

Posted on 2001-07-08
5
Medium Priority
?
538 Views
Last Modified: 2006-11-17
Normally we grant or revoke roles or privileges to/from a schema. Can we do the same to/from a table or any other object?
0
Comment
Question by:k_murli_krishna
  • 3
5 Comments
 
LVL 17

Author Comment

by:k_murli_krishna
ID: 6262541
Please give me a detailed answer.
0
 
LVL 2

Accepted Solution

by:
highmarks earned 200 total points
ID: 6262748
yes you can
grant select on table_name for user_name;
individual granting
0
 
LVL 1

Expert Comment

by:marek_wiechula
ID: 6263742
There are three types of privileges: system privileges, object privileges and role privileges.

A system privilege is a privilege to do something in the database - for example CREATE SESSION.  These privileges can be granted to users (ie. schemas) and/or roles.

An object privilege is a privilege to do something with regards to a particular database object - for example, to SELECT from a particular table, to INSERT into a particular table, to EXECUTE a particular procedure.These privileges can be granted only on a specific database object by users (schemas) with grant authority on them.  (A user can have grant authority by owning the object, or by having the privilege granted to him with the GRANT option.)  There is no statement that allows you to grant SELECT on all the tables in a particular schema to a particular user, you have to specify each table individually.  Also you cannot issue a default grant that applies to tables that haven't even been created yet.

Object privileges can be granted to users (schemas) or roles.

Role privileges (ie roles) can be granted to users or to other roles.

Where ever you might grant something to a user can also grant it to PUBLIC.  Then it becomes available to all the users, even those users that get created later will have the privilege.

When you grant a privilege through a role the user cannot use it to create a database object.  For example, suppose you have a table TAB_NEWS with fields ITEM, SEQID, TIMESTAMP, NEWSLINE and you grant SELECT on that TABLE to the role READ_NEWS.  Assume you have a public synonym for that table.  Then a user with that role can issue the command

SELECT NEWSLINE FROM TAB_NEWS WHERE TIMESTAMP > SYSDATE - 3 ORDER BY TIMESTAMP, ITEM, SEQID;

that will show him the news from the last 3 days.  He cannot create a view LAST_3_DAYS with the command:

CREATE VIEW LAST_3_DAYS AS SELECT NEWSLINE FROM TAB_NEWS WHERE TIMESTAMP > SYSDATE - 3 ORDER BY TIMESTAMP, ITEM, SEQID;

This is because the object (the view) would depend on a privilege he had through a role.

If you had granted SELECT on TAB_NEWS to PUBLIC, then he could have created the view.  However he could not have granted SELECT on his view to anyone else.  The only solution to that would be for you to grant SELECT on TAB_NEWS to PUBLIC with the GRANT option.  Then he could have granted SELECT on his view to other users.

Besides views this also applies to procedures, packages and functions.  However you do not have the option of granting a privilege to the object directly.  If you want user ABC to be able to create the view LAST_3_DAYS on your table, then you have to grant the privilege to the user, you cannot grant it specifically to the VIEW.  (And similarly you cannot grant object privileges directly to a PROCEDURE, PACKAGE or FUNCTION.)

0
 
LVL 17

Author Comment

by:k_murli_krishna
ID: 6265111
Dear Mr. Highmarks,
                   If you would like more than allocated 50 points, please be elaborate like Mr. Marek_wiechula. He has given a comrehensive answer. But to my question, yours is a precise answer assuming i am good. But I have started off 5 months ago and for a weak case like me more upload is required. Anyway, thanx a ton, your answer was equally viable.

with regards
( K. Murli Krishna )
0
 
LVL 17

Author Comment

by:k_murli_krishna
ID: 6265360
Dear Mr. Warek_wiechula,
                        I love you. You gave such a fantastic answer that i am dumbfounded. I have started off as oracle dba in effect 4 months back. I accepted Mr. Highmarks comment as a answer and graded him A with 50 unchanged points since he gave a very precise answer. I want to accept yours and give you 75 points but somehow that button stands disabled. My mailid is kmkrishna@dev.vsofti.stph.net.

with regards

( K. Murli Krishna )
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.

601 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question