Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

table level privileges

Posted on 2001-07-08
5
Medium Priority
?
532 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

604 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