Solved

table level privileges

Posted on 2001-07-08
5
518 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 50 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
Via a live example, show how to take different types of Oracle backups using RMAN.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

762 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now