Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

how to grant select privilege on all sequences within the schema

Posted on 2009-05-20
4
Medium Priority
?
5,207 Views
Last Modified: 2013-12-18
Hi,
 I have around 30 sequences within a schema say schema_xyz. I would like to give select privilege on all the sequences. What is the best way or command to do it. Any links, resources, sample code, ideas highly appreciated. Thanks in advance.
0
Comment
Question by:gudii9
[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
4 Comments
 
LVL 57

Assisted Solution

by:Raja Jegan R
Raja Jegan R earned 600 total points
ID: 24431720
You can select All Sequences available using the below query

SELECT 'GRANT SELECT ON ' || SCHEMA || '.' || sequencename || 'TO hr;' as grant_stmt
FROM ALL_CATALOG
WHERE TABLE_TYPE = 'SEQUENCE'

Once you have the list, you can execute the dynamic sql statements in a cursor loop for all Sequences.
0
 
LVL 16

Accepted Solution

by:
Milleniumaire earned 800 total points
ID: 24431846
Create the following script and call it grant.sql

set heading off pagesize 0 feedback off
spool grantscript.sql

select 'grant select on '||sequence_owner||'.'||sequence_name||' to xyz;'
from all_sequences
where sequence_owner = 'MYUSER;

spool off
@grantscript.sql

exit;

Run the above from sqlplus as follows:

sqlplus username/password @grant

Obviously you will need to change MYUSER and xyz as appropriate.
0
 
LVL 35

Assisted Solution

by:johnsone
johnsone earned 600 total points
ID: 24433378
This should work as well.

You need to replace schema_abc with the schema you want to grant the privileges to.
begin
  for c1rec in (select 'grant select on ' || sequence_owner || '.' || sequence_name || ' to schema_abc' stmt from dba_sequences where sequence_owner = 'SCHEMA_XYZ') loop
    execute immediate c1rec.stmt;
  end loop;
end;
/

Open in new window

0
 
LVL 7

Author Closing Comment

by:gudii9
ID: 31583502
thank you
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
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 recover a database from a user managed backup

688 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