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 privilages

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-08-08, 01:30
Pawan Kumar Pawan Kumar is offline
Registered User
 
Join Date: Mar 2008
Posts: 120
select privilages

Hi,
I want to give select persmissons to perticular user or anyone can select only except one main user.

What are the steps?

Regards
Pawan
__________________
Regards
Pawan Kumar
Reply With Quote
  #2 (permalink)  
Old 07-08-08, 03:30
aflorin27 aflorin27 is offline
Registered User
 
Join Date: Apr 2008
Location: Iasi, Romania
Posts: 317
to grant select privileges on a table to a single user, you will use:
GRANT SELECT ON TABLE table_name TO USER user_name

to grant this permission to everyone but a single user, you must create a group in which you will include everyone (except that user) and you will use:
GRANT SELECT ON TABLE table_name TO GROUP group_name
Reply With Quote
  #3 (permalink)  
Old 07-08-08, 03:30
Peter.Vanroose Peter.Vanroose is offline
Registered User
 
Join Date: Sep 2004
Location: Belgium
Posts: 1,079
Quote:
Originally Posted by Pawan Kumar
I want to give select permissons to particular user
GRANT SELECT ON TABLE tablename1, tablename2, viewname3, ... TO user-id ;
Quote:
Originally Posted by Pawan Kumar
or anyone can select only except one main user.
GRANT SELECT ON TABLE tablename1, tablename2, viewname3, ... TO PUBLIC ;
GRANT ALL ON TABLE tablename, ... TO main-user ;
(Or make sure that main-user is the table owner, who always has ALL privileges.)
__________________
--_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 07-08-08, 04:01
Pawan Kumar Pawan Kumar is offline
Registered User
 
Join Date: Mar 2008
Posts: 120
thanks....

If i create a new user C on linux server...
and on this server there are running two instances A and B with users A and B respectively....I want to access databases of A and B by user C and want to give select privilages to C user for databases running under A and B.

how can we do this?
__________________
Regards
Pawan Kumar
Reply With Quote
  #5 (permalink)  
Old 07-08-08, 04:10
aflorin27 aflorin27 is offline
Registered User
 
Join Date: Apr 2008
Location: Iasi, Romania
Posts: 317
On each database:
GRANT CONNECT ON DATABASE TO USER C

and then use the grants above
Reply With Quote
  #6 (permalink)  
Old 07-08-08, 04:36
Pawan Kumar Pawan Kumar is offline
Registered User
 
Join Date: Mar 2008
Posts: 120
I logged in by User A and gave grant permissiong to user B..
su - A
first asking for database connection...
db2 connect to A
then i did
db2 GRANT CONNECT ON DATABASE TO USER B
DB20000I The SQL command completed successfully.

now login by User B
su - B
and try to connect database A but througing below
db2 connect to A user A using **
SQL1013N The database alias name or database name "A" could not be found.
SQLSTATE=42705


what I need to do?
__________________
Regards
Pawan Kumar
Reply With Quote
  #7 (permalink)  
Old 07-08-08, 08:44
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Quote:
Originally Posted by Pawan Kumar

what I need to do?
CATALOG DATABASE A ...
Reply With Quote
  #8 (permalink)  
Old 07-09-08, 01:35
Pawan Kumar Pawan Kumar is offline
Registered User
 
Join Date: Mar 2008
Posts: 120
by cataloging my requirement is not being full...
__________________
Regards
Pawan Kumar
Reply With Quote
  #9 (permalink)  
Old 07-09-08, 03:23
nick.ncs nick.ncs is offline
Registered User
 
Join Date: May 2007
Location: somewhere in dbforums
Posts: 221
Quote:
Originally Posted by Pawan Kumar
I logged in by User A and gave grant permissiong to user B..
su - A
first asking for database connection...
db2 connect to A
then i did
db2 GRANT CONNECT ON DATABASE TO USER B
DB20000I The SQL command completed successfully.

now login by User B
su - B
and try to connect database A but througing below
db2 connect to A user A using **
SQL1013N The database alias name or database name "A" could not be found.
SQLSTATE=42705


what I need to do?
In this specific scenario you have to follow the following steps

first do
su - A
first asking for database connection...
db2 connect to A
then i did
db2 GRANT CONNECT ON DATABASE TO USER B
DB20000I The SQL command completed successfully.

then get details of instance for database A

then do
su - B

now you'll have to catalog the instance A using the following command
db2 catalog tcpip node <<nodename>> remote <<db2server ip>> server <<pot of node>>

now do 'db2 list node directory' and check whether the node has been cataloged

now you'll have to catalog the database

db2 catalog db <<dbname>> as alias <<alias-name>> at node <<nodename>>

where nodename is the same as the node that is specified while cataloging the node
[ points to note - database alias name cannot be same as an existing alias name or a db name ]

now do 'db2 list db directory' and check whether the database A details is displayed

now do
connect to A user <<username>> using <<password>>
[ in this case use the alias name that you have specified for database A ]
Reply With Quote
  #10 (permalink)  
Old 07-09-08, 04:16
Pawan Kumar Pawan Kumar is offline
Registered User
 
Join Date: Mar 2008
Posts: 120
thanks to all
__________________
Regards
Pawan Kumar
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