If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > select privilege

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-09-08, 06:42
azs0309 azs0309 is offline
Registered User
 
Join Date: Jan 2008
Posts: 88
select privilege

Hi,

may be a basic question...but does anyone know that how to give select(or any privilege ) on all the tables for that database in one command to a particular user.

like if i want to give only select access to a user on all the database den i have to give a seperate commad for all the table. So I wanted to give in using one command.

please let me know if anyone has any idea
Reply With Quote
  #2 (permalink)  
Old 01-09-08, 07:08
umayer umayer is offline
Registered User
 
Join Date: Dec 2005
Posts: 273
There is no generic GRANT table-privilege for all tables of a database. You have to list each table.
Of course you can generate the GRANT-statements with SQL.

e.g.

SELECT
' GRANT SELECT ON TABLE '
concat STRIP(creator)
concat '.'
concat STRIP(name)
concat ' TO userid ; '
FROM SYSIBM.SYSTABLES
WHERE DBNAME = 'your-DBname' ;
Reply With Quote
  #3 (permalink)  
Old 01-09-08, 15:39
Peter.Vanroose Peter.Vanroose is offline
Registered User
 
Join Date: Sep 2004
Location: Belgium
Posts: 1,079
Quote:
Originally Posted by umayer
There is no generic GRANT table-privilege for all tables of a database.
But by granting the DBADM privilege, the user gets SELECT auth (and much more) on all tables of a database -- that is, on DB2 for z/OS.
Is this also the case for L/U/W or iSeries?
__________________
--_Peter Vanroose,
__IBM Certified Database Administrator, DB2 9 for z/OS
__IBM Certified Application Developer
__ABIS Training and Consulting
__http://www.abis.be/
Reply With Quote
  #4 (permalink)  
Old 01-09-08, 15:59
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
Quote:
Originally Posted by Peter.Vanroose
But by granting the DBADM privilege, the user gets SELECT auth (and much more) on all tables of a database -- that is, on DB2 for z/OS.
Is this also the case for L/U/W or iSeries?
It is the same for LUW.

Andy
Reply With Quote
  #5 (permalink)  
Old 01-10-08, 01:09
azs0309 azs0309 is offline
Registered User
 
Join Date: Jan 2008
Posts: 88
But I want to only give select authority i.e. read only.
Reply With Quote
  #6 (permalink)  
Old 01-10-08, 01:58
Peter.Vanroose Peter.Vanroose is offline
Registered User
 
Join Date: Sep 2004
Location: Belgium
Posts: 1,079
Quote:
Originally Posted by azs0309
But I want to only give select authority i.e. read only.
In that case your only option is to give it on a table-by-table basis.
Use UMayer's suggestion for generating the GRANT statements.
Be aware that there is no way of automatically granting SELECT auth for "future", i.e., not yet existing, tables!
__________________
--_Peter Vanroose,
__IBM Certified Database Administrator, DB2 9 for z/OS
__IBM Certified Application Developer
__ABIS Training and Consulting
__http://www.abis.be/
Reply With Quote
  #7 (permalink)  
Old 01-10-08, 02:02
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
I wonder if it is possible to put an insert trigger on syscat.tables to do this?
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #8 (permalink)  
Old 01-10-08, 02:46
Peter.Vanroose Peter.Vanroose is offline
Registered User
 
Join Date: Sep 2004
Location: Belgium
Posts: 1,079
Quote:
Originally Posted by Marcus_A
I wonder if it is possible to put an insert trigger on syscat.tables to do this?
Good idea! Never tried that.
Actually, shouldn't it be on sysibm.systables instead? I seem to recall that syscat.tables is a view on sysibm.systables.
There could be restrictions on putting GRANT statements in triggers, though. I've had issues with that on z/OS.
__________________
--_Peter Vanroose,
__IBM Certified Database Administrator, DB2 9 for z/OS
__IBM Certified Application Developer
__ABIS Training and Consulting
__http://www.abis.be/
Reply With Quote
  #9 (permalink)  
Old 01-10-08, 07:45
umayer umayer is offline
Registered User
 
Join Date: Dec 2005
Posts: 273
Quote:
Originally Posted by Marcus_A
I wonder if it is possible to put an insert trigger on syscat.tables to do this?

no.
Catalog tables, auxiliary tables, temporary tables and MQTs
can't be specified as the triggering table
( alias or synonyms can't be specified, too )
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On