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 > How to make already existing table to be read-only?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-09-08, 07:54
aveerabadran aveerabadran is offline
Registered User
 
Join Date: Mar 2008
Posts: 11
How to make already existing table to be read-only?

Hi,

I want to make a already existing DB2 table to be read-only. Can anyone let me know the command for doing that?

I am using DB2 - V8.1/Linux OS

Thanks,
Arunvijay.
Reply With Quote
  #2 (permalink)  
Old 04-09-08, 07:56
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
You could use the REVOKE statement to revoke insert, update, and delete authorization from certain users or groups.
Reply With Quote
  #3 (permalink)  
Old 04-09-08, 09:03
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Or you create a small program that locks the table in shared mode, which will also prevent DBAs from bypassing the privilege checking. (But then, a SYSADM could force this program and it wouldn't be water-tight.)
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #4 (permalink)  
Old 04-09-08, 19:10
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
Quote:
Originally Posted by stolze
Or you create a small program that locks the table in shared mode, which will also prevent DBAs from bypassing the privilege checking. (But then, a SYSADM could force this program and it wouldn't be water-tight.)
I wonder if that would cause the logs to go into secondary extents because the transaction is still open?
__________________
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
  #5 (permalink)  
Old 04-10-08, 03:29
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
No, it wouldn't. Since the lock does not cause a log record to be written, the locking transaction does not refer to any active log file.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #6 (permalink)  
Old 04-10-08, 04:50
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
Quote:
Originally Posted by stolze
No, it wouldn't. Since the lock does not cause a log record to be written, the locking transaction does not refer to any active log file.
Doesn't DB2 have to record the beginning of the UOW? Maybe not, but in any case, I don't think it is a good idea to hold locks like that.
__________________
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
  #7 (permalink)  
Old 04-10-08, 04:55
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
The beginning of the UOW is needed only when the first data modification occurs. In fact, transactions with only queries do not appear at all in the log - at least that's how things worked in DB2 LUW V8, and I doubt that this changed in V9.

And I fully agree: holding locks like that is not smart at all, for example, if lock timeout is set to infinity...
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
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