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 > Replace view - privilege in DB2 9.7

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-15-11, 05:32
blazer789 blazer789 is offline
Registered User
 
Join Date: Jun 2009
Posts: 221
Replace view - privilege in DB2 9.7

A user has a DBADM and DataAccess privilege in 9.7 but when it tries to Create or Replace a view, it fails with an error complaining that the user doesn't have the required privilege. Please let me know if the user needs to have any other privilege other than DBADM/DATAACESS in order to create/replace view.

Any help in this regard is much appreciated !!
Reply With Quote
  #2 (permalink)  
Old 07-15-11, 05:44
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
To create a view, the privileges you hold seems to be sufficient
IBM DB2 9.7 for Linux, UNIX and Windows Information Center

But to replace, there is another condition
Quote:
To replace an existing view, the authorization ID of the statement must be the owner of the existing view (SQLSTATE 42501).
If the authid is not the owner, then from a SECADM user, issue TRANSFER OWNERSHIP (lookup docs for syntax) and perform the replace action.
Of course, the other option is to use the current owner to replace the view.

HTH

Sathyaram
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #3 (permalink)  
Old 07-15-11, 06:19
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
Interestingly, I believe that DBADM can drop and re-create the view, even if it is not the owner.
__________________
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
  #4 (permalink)  
Old 07-16-11, 13:01
blazer789 blazer789 is offline
Registered User
 
Join Date: Jun 2009
Posts: 221
@Sathyaram: Thanks !!

@Marcus: You are right. I followed the same workaround to resolve the issue. Instead of replacing the view, I dropped and recreated it.
Reply With Quote
  #5 (permalink)  
Old 07-17-11, 22:03
blazer789 blazer789 is offline
Registered User
 
Join Date: Jun 2009
Posts: 221
We frequently do redirected restores of PROD data into our lower env's like QA. After the restore, some of the DDL using CREATE or REPLACE a new feature in db2 9.7 is failing saying only the owner of the object can invoke CREATE or REPLACE. The instance ID of PROD is still the owner of the objects in the lower env's after the restore, so we are not able to use the CREATE or REPLACE. As part of the redirected restore or through any other process/config can we make the instance ID of the lower lanes as owner of all objects to fix this issue? IF we cant use CREATE or REPLACE, we have to do 3 times more work for DDL with DROP and CREATE as lot of dependencies exist. Please advise.

I understand that we can do a transfer ownership for each and every single object after the restore. But is there any other easier way to accomplish this ??
Reply With Quote
  #6 (permalink)  
Old 07-18-11, 04:38
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
Blazer789, AFAIK there isn't a short-cut for chaning ownership.

BTW, changing ownership is lot easier than you might imaging.

A view with all object owners info :

OBJECTOWNERS

and create a script to build and execute transfer ownerships using the view.

DB2 Database for Linux, UNIX, and Windows

I hope you already have the process for granting SECADM to a new user. The SECADM issuing this command cannot transfer ownership to itself.

HTH

Sathyaram
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #7 (permalink)  
Old 07-18-11, 21:04
blazer789 blazer789 is offline
Registered User
 
Join Date: Jun 2009
Posts: 221
Thanks Satya for your kind response. When I say an alternate way to accomplish this, I meant to ask if there is any way the objects in the lowerlane get the ownership of the instance id of the lower lane through an option in restore.

For example:
"A" is the instance user of database "d1". "A" owns all the objects in "d1".
"B" is the instance user of database "d2". "B" owns all the objects in "d2".

"d1" is restored on to "d2". Now "d2" is located on instance "B" but all the objects are owned by user "A". Now when I try to run "create or replace view" on the newly restored database with user B it fails complaining that "B" is not the owner of the object. So I am looking for an option in restore or someother process with which all the objects in the newly restored database would be owned by user "B" after the restore.
Reply With Quote
  #8 (permalink)  
Old 07-19-11, 03:38
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
@Blazer789 , Yes I did get your point, but unfortunately(AFAIK) changing ownership during a redirected restore is not possible

HTH

Sathyaram
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #9 (permalink)  
Old 07-19-11, 11:45
blazer789 blazer789 is offline
Registered User
 
Join Date: Jun 2009
Posts: 221
Okay, Thanks !
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