ibm-information-center/dist/eclipse/plugins/i5OS.ic.db2_5.4.0.1/rbafzmsth2lockt.htm

123 lines
7.1 KiB
HTML

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="dc.language" scheme="rfc1766" content="en-us" />
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<meta name="dc.date" scheme="iso8601" content="2005-09-19" />
<meta name="copyright" content="(C) Copyright IBM Corporation 1998, 2006" />
<meta name="security" content="public" />
<meta name="Robots" content="index,follow"/>
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
<meta name="keywords" content="LOCK TABLE statement, LOCK TABLE, SQL statements,
table spaces, locking, with LOCK TABLE statement, concurrency,
in LOCK TABLE statement, table-name, IN SHARE MODE clause, SHARE MODE clause,
SHARE, IN EXCLUSIVE MODE clause, MODE, ALLOW READ clause, EXCLUSIVE,
IN EXCLUSIVE clause, EXCLUSIVE MODE clause" />
<title>LOCK TABLE</title>
<link rel="stylesheet" type="text/css" href="ibmidwb.css" />
<link rel="stylesheet" type="text/css" href="ic.css" />
</head>
<body>
<a id="Top_Of_Page" name="Top_Of_Page"></a><!-- Java sync-link -->
<script language = "Javascript" src = "../rzahg/synch.js" type="text/javascript"></script>
<a name="h2lockt"></a>
<h2 id="h2lockt"><a href="rbafzmst02.htm#ToC_1170">LOCK TABLE</a></h2><a id="idx2906" name="idx2906"></a><a id="idx2907" name="idx2907"></a><a id="idx2908" name="idx2908"></a><a id="idx2909" name="idx2909"></a><a id="idx2910" name="idx2910"></a>
<a name="lock"></a>
<p id="lock">The LOCK TABLE statement either prevents concurrent application
processes from changing a table or prevents concurrent application processes
from using a table.</p>
<a name="wq1637"></a>
<h3 id="wq1637"><a href="rbafzmst02.htm#ToC_1171">Invocation</a></h3>
<p>This statement can be embedded in an application program or issued interactively.
It is an executable statement that can be dynamically prepared.</p>
<a name="wq1638"></a>
<h3 id="wq1638"><a href="rbafzmst02.htm#ToC_1172">Authorization</a></h3>
<p>The privileges held by the authorization ID of the statement must include
at least one of the following: </p>
<ul>
<li>For the table identified in the statement,
<ul>
<li>The system authority of *OBJOPR on the table, and</li>
<li>The system authority *EXECUTE on the library containing the table</li></ul></li>
<li>Administrative authority</li></ul>
<a name="wq1639"></a>
<h3 id="wq1639"><a href="rbafzmst02.htm#ToC_1173">Syntax</a></h3>
<a href="rbafzmsth2lockt.htm#deslocj"><img src="c.gif" alt="Click to skip syntax diagram" /></a>
<pre class="cgraphic"><span><img src="c.gif" alt="Read syntax diagram" longdesc="rbafzmstsyn359.htm"
border="0" /></span><a href="#skipsyn-358"><img src="c.gif" alt="Skip visual syntax diagram"
border="0" /></a>>>-LOCK TABLE--<span class="italic">table-name</span>--IN--+-SHARE MODE----------------+--->&lt;
+-EXCLUSIVE MODE ALLOW READ-+
'-EXCLUSIVE MODE------------'
</pre>
<a name="skipsyn-358" id="skipsyn-358"></a>
<a name="deslocj"></a>
<h3 id="deslocj"><a href="rbafzmst02.htm#ToC_1174">Description</a></h3>
<dl class="parml">
<dt class="bold"><var class="pv">table-name</var> </dt><a id="idx2911" name="idx2911"></a>
<dd>Identifies the table to be locked. The table-name must identify a base
table that exists at the current server, but must not identify a catalog table
or a global temporary table.
</dd>
<dt class="bold">IN SHARE MODE </dt><a id="idx2912" name="idx2912"></a><a id="idx2913" name="idx2913"></a><a id="idx2914" name="idx2914"></a><a id="idx2915" name="idx2915"></a>
<dd>Prevents concurrent application processes from executing any but read-only
operations on the table.
<p>A shared lock (*SHRNUP) is acquired for the application
process in which the statement is executed. Other application processes may
also acquire a shared lock (*SHRNUP) and prevent this application process
from executing any but read-only operations.</p>
</dd>
<dt class="bold">IN EXCLUSIVE MODE ALLOW READ</dt><a id="idx2916" name="idx2916"></a><a id="idx2917" name="idx2917"></a><a id="idx2918" name="idx2918"></a><a id="idx2919" name="idx2919"></a>
<dd>Prevents concurrent application processes from executing any but read-only
operations on the table.
<p>An exclusive allow read lock (*EXCLRD) is acquired
for the application process in which the statement is executed. Other application
processes may not acquire a shared lock (*SHRNUP) and cannot prevent this
application process from executing updates, deletes, and inserts on the table.</p>
</dd>
<dt class="bold">IN EXCLUSIVE MODE </dt><a id="idx2920" name="idx2920"></a><a id="idx2921" name="idx2921"></a><a id="idx2922" name="idx2922"></a><a id="idx2923" name="idx2923"></a>
<dd>Prevents concurrent application processes from executing any operations
at all on the table.
<p>An exclusive lock (*EXCL) is acquired for the application
process in which the statement is executed.</p>
</dd>
</dl>
<a name="wq1640"></a>
<h3 id="wq1640"><a href="rbafzmst02.htm#ToC_1175">Notes</a></h3>
<p><span class="bold">Locks obtained:</span> Locking is used to prevent concurrent
operations.</p>
<p>The lock is released: </p>
<ul>
<li>When the unit of work ends, unless the unit of work is ended by a COMMIT
HOLD or ROLLBACK HOLD</li>
<li>When the first SQL program in the program stack ends, unless CLOSQLCSR(*ENDJOB)
or CLOSQLCSR(*ENDACTGRP) was specified on the CRTSQLxxx command</li>
<li>When the activation group ends</li>
<li>When the connection is changed using a CONNECT (Type 1) statement</li>
<li>When the connection associated with the lock is disconnected using the
DISCONNECT statement</li>
<li>When the connection is in the release-pending state and a successful COMMIT occurs</li></ul>
<p>You may also issue the Deallocate Object (DLCOBJ) command to unlock the
table.</p>
<p>Conflicting locks already held by other application processes will cause
your application to wait up to the default wait time of the job.</p>
<a name="wq1641"></a>
<h3 id="wq1641"><a href="rbafzmst02.htm#ToC_1176">Example</a></h3>
<p>Obtain a lock on the DEPARTMENT table.</p>
<pre class="xmp"> <span class="bold">LOCK TABLE</span> DEPARTMENT <span class="bold">IN EXCLUSIVE MODE</span></pre><a id="idx2924" name="idx2924"></a><a id="idx2925" name="idx2925"></a>
<hr /><br />
[ <a href="#Top_Of_Page">Top of Page</a> | <a href="rbafzmstlabelon.htm">Previous Page</a> | <a href="rbafzmsthopen.htm">Next Page</a> | <a href="rbafzmst02.htm#wq1">Contents</a> |
<a href="rbafzmstindex.htm#index">Index</a> ]
<a id="Bot_Of_Page" name="Bot_Of_Page"></a>
</body>
</html>