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

158 lines
10 KiB
HTML
Raw Permalink Normal View History

2024-04-02 14:02:31 +00:00
<?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="RENAME statement, RENAME, SQL statements,
renaming SQL objects, TABLE clause, in RENAME statement, table-name, view-name,
SYSTEM NAME clause, INDEX clause, index-name, SQL (Structured Query Language)" />
<title>RENAME</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="rena"></a>
<h2 id="rena"><a href="rbafzmst02.htm#ToC_1212">RENAME</a></h2><a id="idx2998" name="idx2998"></a><a id="idx2999" name="idx2999"></a><a id="idx3000" name="idx3000"></a>
<a name="rename"></a>
<p id="rename">The RENAME statement renames a table, view, or index. The name
and/or the system object name of the table, view, or index can be changed.</p>
<a name="wq1677"></a>
<h3 id="wq1677"><a href="rbafzmst02.htm#ToC_1213">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="wq1678"></a>
<h3 id="wq1678"><a href="rbafzmst02.htm#ToC_1214">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>The following system authorities:
<ul>
<li>If the name of the object is changed:
<ul>
<li>The system authority of *OBJMGT on the table, view, or index to be renamed</li>
<li>The system authority *EXECUTE on the library containing the table, view,
or index to be renamed</li></ul></li>
<li>If the system name of the object is changed:
<ul>
<li>The system authority of *OBJMGT on the table, view, or index to be renamed</li>
<li>The system authorities *EXECUTE and *UPD on the library containing the
table, view, or index to be renamed</li></ul></li></ul></li>
<li>Administrative authority</li></ul>
<a name="wq1679"></a>
<h3 id="wq1679"><a href="rbafzmst02.htm#ToC_1215">Syntax</a></h3>
<a href="rbafzmstrena.htm#synsrename"><img src="c.gif" alt="Click to skip syntax diagram" /></a>
<pre class="cgraphic"><span><img src="c.gif" alt="Read syntax diagram" longdesc="rbafzmstsyn366.htm"
border="0" /></span><a href="#skipsyn-365"><img src="c.gif" alt="Skip visual syntax diagram"
border="0" /></a> .-TABLE-.
>>-RENAME--+-+-------+--+-<span class="italic">table-name</span>-+-+------------------------>
| '-<span class="italic">view-name</span>--' |
'-INDEX--<span class="italic">index-name</span>---------'
>--TO--+-<span class="italic">new-table-identifier</span>--+-------------------------------------------+-+->&lt;
| '-FOR SYSTEM NAME--<span class="italic">system-object-identifier</span>-' |
'-SYSTEM NAME--<span class="italic">system-object-identifer</span>--------------------------------'
</pre>
<a name="skipsyn-365" id="skipsyn-365"></a>
<a name="synsrename"></a>
<h3 id="synsrename"><a href="rbafzmst02.htm#ToC_1216">Description</a></h3>
<dl class="parml">
<dt class="bold">TABLE <var class="pv">table-name</var><span class="base"> or </span> <var class="pv">view-name</var> </dt><a id="idx3001" name="idx3001"></a><a id="idx3002" name="idx3002"></a><a id="idx3003" name="idx3003"></a><a id="idx3004" name="idx3004"></a>
<dd>Identifies the table or view that will be renamed. The <span class="italic">table-name</span> or <span class="italic">view-name</span> must identify a table
or view that exists at the current server, but must not identify a catalog
table or a global temporary table. The specified name can be an alias name.
The specified table or view is renamed to the new name. All privileges, constraints,
indexes, triggers, views, and logical files on the table or view are preserved.
<p>Any access plans that reference the table or view are implicitly prepared
again when a program that uses the access plan is next run. Since the program
refers to a table or view with the original name, if a table or view with
the original name does not exist at that time, an error is returned.</p>
</dd>
<dt class="bold">INDEX <var class="pv">index-name</var> </dt><a id="idx3005" name="idx3005"></a><a id="idx3006" name="idx3006"></a>
<dd>Identifies the index that will be renamed. The <span class="italic">index-name</span> must identify an index that exists at the current server. The specified
index is renamed to the new name.
<p>Any access plans that reference the index
are not affected by rename.</p>
</dd>
<dt class="bold"><var class="pv">new-table-identifier</var></dt>
<dd>Identifies the new <span class="italic">table-name</span>, <span class="italic">view-name</span>, or <span class="italic">index-name</span> of the table, view,
or index, respectively. <span class="italic">new-table-identifier</span> must
not be the same as a table, view, alias, or index that already exists at the
current server. The <span class="italic">new-table-identifier</span> must be an
unqualified SQL identifier.
</dd>
<dt class="bold">SYSTEM NAME <var class="pv">system-object-identifier</var></dt>
<dd>Identifies the new <span class="italic">system-object-identifier</span> of
the table, view, or index, respectively. <span class="italic">system-object-identifier</span> must not be the same as a table, view, alias, or index that already
exists at the current server. The <span class="italic">system-object-identifier</span> must be an unqualified system identifier.
<p>If the name of the object
and the system name of the object are the same and <span class="italic">new-table-identifier</span> is not specified, specifying <span class="italic">system-object-identifier</span> will be the new name and system object name. Otherwise, specifying <span class="italic">system-object-identifier</span> will only affect the system name
of the object and not affect the name of the object.</p>
<p>If both <span class="italic">new-table-identifier</span> and <span class="italic">system-object-identifier</span> are specified, they cannot both be valid system object names.</p>
</dd>
</dl>
<a name="wq1680"></a>
<h3 id="wq1680"><a href="rbafzmst02.htm#ToC_1217">Notes</a></h3>
<p><span class="bold">Effects of the statement:</span> The specified table is
renamed to the new name. All privileges, constraints, and indexes on the table
are preserved.</p>
<p>Any access plans that refer to that table are invalidated. For more information
see <a href="rbafzmstpackageap.htm#packageap">Packages and access plans</a>.</p>
<p><span class="bold">Considerations for aliases:</span> If an alias name is specified
for <var class="pv">table-name</var>, the table must exist at the current server, and the
table that is identified by the alias is renamed. The name of the alias is
not changed and continues to refer to the old table name after the rename.</p>
<p>There is no support for changing the name of an alias with the RENAME statement.
To change the name to which the alias refers, the alias must be dropped and
recreated.</p>
<p><span class="bold">Rename rules:</span> The rename operation performed depends
on the new name specified.</p>
<ul>
<li>If the new name is a valid system identifier,
<ul>
<li>the alternative name (if any) is removed, and</li>
<li>the system object name is changed to the new name.</li></ul></li>
<li>If the new name is not a valid system identifier,
<ul>
<li>the alternative name is added or changed to the new name, and</li>
<li>a new system object name is generated if the system object name (of the
table or view) was specified as the table, view, or index to rename. For more
information about generated table name rules, see <a href="rbafzmsthctabl.htm#namrul">Rules for Table Name Generation</a>.</li></ul></li></ul>
<p>If an alias name is specified for <span class="italic">table-name</span>, the
alias must exist at the current server, and the table that is identified by
the alias is renamed. The name of the alias is not changed and continues to
refer to the old table after the rename. There is no support for changing
the name of an alias.</p>
<a name="wq1681"></a>
<h3 id="wq1681"><a href="rbafzmst02.htm#ToC_1218">Examples</a></h3>
<p><span class="italic">Example 1</span>: Rename a table named MY_IN_TRAY
to MY_IN_TRAY_94. The system object name will remain unchanged (MY_IN_TRAY). </p>
<pre class="xmp"> <span class="bold">RENAME TABLE</span> MY_IN_TRAY <span class="bold">TO</span> MY_IN_TRAY_94
<span class="bold">FOR SYSTEM NAME</span> MY_IN_TRAY</pre>
<p><span class="italic">Example 2</span>: Rename a table named MA_PROJ to MA_PROJ_94. </p>
<pre class="xmp"> <span class="bold">RENAME TABLE</span> MA_PROJ
<span class="bold">TO SYSTEM NAME</span> MA_PROJ_94</pre>
<p><a id="idx3007" name="idx3007"></a><a id="idx3008" name="idx3008"></a><a id="idx3009" name="idx3009"></a><a id="idx3010" name="idx3010"></a></p>
<hr /><br />
[ <a href="#Top_Of_Page">Top of Page</a> | <a href="rbafzmstrlssvpt.htm">Previous Page</a> | <a href="rbafzmstrudtp.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>