Solved

how to grant select privilege on all sequences within the schema

Posted on 2009-05-20
4
2,680 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
4 Comments
 
LVL 57

Assisted Solution

by:Raja Jegan R
Raja Jegan R earned 150 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 200 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 34

Assisted Solution

by:johnsone
johnsone earned 150 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

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…
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…
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.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

744 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

13 Experts available now in Live!

Get 1:1 Help Now