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 > User privileges

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-05-11, 06:58
shore shore is offline
Registered User
 
Join Date: Aug 2011
Location: Mumbai,India
Posts: 49
User privileges

Hi,

I want to create an user which will be able to create tables,views and other database objects but it will not be able to drop those objects.

Is it possible to revoke drop privilege of an object from its creator???


DB2 V9.5
Reply With Quote
  #2 (permalink)  
Old 09-05-11, 07:14
przytula_guy przytula_guy is offline
Registered User
 
Join Date: Apr 2006
Location: Belgium
Posts: 1,159
see : DROPIN
Revokes the privilege to drop objects in the schema.
REVOKE (Schema Privileges)
__________________
Best Regards, Guy Przytula
Database Software Consultant
DB2 UDB LUW Certified V7-V8-V9-V9.7 DB Admin - Dprop..
Information Server Datastage Certified
http://www.infocura.be
Reply With Quote
  #3 (permalink)  
Old 09-05-11, 07:16
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
I don't think it is possible to revoke drop privilege from the user.

Why do you want to do this ?

You can transfer the ownership of the object to someone else and grant the original creator only selective priivileges. Look at TRANSFER OWNERSHIP command.

-
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #4 (permalink)  
Old 09-05-11, 07:19
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
Guy,
As per documentation : (http://publib.boulder.ibm.com/infoce...Fr0000988.html )

Quote:



When dropping objects that allow two-part names, the privileges held by the authorization ID of the statement must include at least one of the following:
  • DROPIN privilege on the schema for the object
  • Owner of the object, as recorded in the OWNER column of the catalog view for the object
  • CONTROL privilege on the object (applicable only to indexes, index specifications, nicknames, packages, tables, and views) <LI class=li>Owner of the user-defined type, as recorded in the OWNER column of the SYSCAT.DATATYPES catalog view (applicable only when dropping a method that is associated with a user-defined type)
  • SYSADM or DBADM authority

So, the owner will be able to drop the object

Sathyaram
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.

Last edited by sathyaram_s; 09-05-11 at 07:21. Reason: added link
Reply With Quote
  #5 (permalink)  
Old 09-05-11, 07:29
shore shore is offline
Registered User
 
Join Date: Aug 2011
Location: Mumbai,India
Posts: 49
Thanks for the info...

but my application require such ID. Is there any alternate way to achive the same??
Reply With Quote
  #6 (permalink)  
Old 09-05-11, 07:58
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
So, you don't want the application to inadvertantly drop the table ?

Here, when you create a table, you can create 'WITH RESTRICT ON DROP'
or ALTER the table to be RESTRICT ON DROP
Code:
 db2 "create table t1(i int) with restrict on  drop"
DB20000I  The SQL command completed successfully.
 
 db2 drop table t1
DB21034E  The command was processed as an SQL statement because it was not a
valid Command Line Processor command.  During SQL processing it returned:
SQL0672N  Operation DROP not allowed on table "DB2INST1.T1".  SQLSTATE=55035
 
 db2 "alter table t1   drop restrict on  drop"
DB20000I  The SQL command completed successfully.
 
  db2 drop table t1
DB20000I  The SQL command completed successfully.
As you can see, unless you alter to remove restrict on drop, the table cannot be dropped

HTH
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #7 (permalink)  
Old 09-05-11, 08:01
shore shore is offline
Registered User
 
Join Date: Aug 2011
Location: Mumbai,India
Posts: 49
Thanks Satya... This will work...
Reply With Quote
  #8 (permalink)  
Old 09-07-11, 12:39
Mathew_paul Mathew_paul is offline
Registered User
 
Join Date: Oct 2007
Posts: 200
satya

but the user who is going to create the with this option has the privileges to alter the table to remove this option right and he can drop the table.

regs
Paul
Reply With Quote
  #9 (permalink)  
Old 09-07-11, 19:11
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
Yes, you are right Paul.

If you don't want the user to have any 'automatic' drop privilege on the table, Transfer ownership( the user doesnt even have to be real)
If you want to prevent the user from dropping the table by mistake(an application logic error,say) , then alter the table to restrict drops

If the requirement is any different, then the solution will be too

HTH
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
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