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

172 lines
10 KiB
HTML
Raw 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="CREATE ALIAS statement, CREATE ALIAS,
SQL statements, ALIAS clause, in CREATE ALIAS statement, alias-name, FOR clause,
table-name, view-name" />
<title>CREATE ALIAS</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="hcalias"></a>
<h2 id="hcalias"><a href="rbafzmst02.htm#ToC_837">CREATE ALIAS</a></h2><a id="idx1591" name="idx1591"></a><a id="idx1592" name="idx1592"></a><a id="idx1593" name="idx1593"></a>
<a name="calia"></a>
<p id="calia">The CREATE ALIAS statement defines an alias on a table, partition
of a table, view, or member of a database file at the current server.</p>
<a name="wq1170"></a>
<h3 id="wq1170"><a href="rbafzmst02.htm#ToC_838">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="wq1171"></a>
<h3 id="wq1171"><a href="rbafzmst02.htm#ToC_839">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 privilege to create in the schema. For more information, see <a href="rbafzmstauthown.htm#createin">Privileges necessary to create in a schema</a>.</li>
<li>Administrative authority</li></ul>
<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>*USE to the Create DDM File (CRTDDMF) command</li></ul></li>
<li>Administrative authority</li></ul>
<p>If SQL names are specified and a user profile exists that has the same
name as the library into which the alias is created, and that name is different
from the authorization ID of the statement, then the privileges held by the
authorization ID of the statement must include at least one of the following: </p>
<ul>
<li>The system authority *ADD to the user profile with that name</li>
<li>Administrative authority</li></ul>
<a name="wq1172"></a>
<h3 id="wq1172"><a href="rbafzmst02.htm#ToC_840">Syntax</a></h3>
<a href="rbafzmsthcalias.htm#synscrtalias"><img src="c.gif" alt="Click to skip syntax diagram" /></a>
<pre class="cgraphic"><span><img src="c.gif" alt="Read syntax diagram" longdesc="rbafzmstsyn268.htm"
border="0" /></span><a href="#skipsyn-267"><img src="c.gif" alt="Skip visual syntax diagram"
border="0" /></a>>>-CREATE--ALIAS--<span class="italic">alias-name</span>------------------------------------>
>--FOR--+-<span class="italic">table-name</span>-+--+--------------------------+----------->&lt;
'-<span class="italic">view-name</span>--' '-(--+-<span class="italic">partition-name</span>-+--)-'
'-<span class="italic">member-name</span>----'
</pre>
<a name="skipsyn-267" id="skipsyn-267"></a>
<a name="synscrtalias"></a>
<h3 id="synscrtalias"><a href="rbafzmst02.htm#ToC_841">Description</a></h3>
<dl class="parml">
<dt class="bold"><var class="pv">alias-name</var> </dt><a id="idx1594" name="idx1594"></a>
<dd>Names the alias. The name, including the implicit or explicit qualifier,
must not be the same as an index, table, view, alias or file that already
exists at the current server.
<p>If SQL names were specified, the alias will
be created in the schema specified by the implicit or explicit qualifier.</p>
<p>If system names were specified, the alias will be created in the schema
that is specified by the qualifier. If not qualified, the alias will be created
in the same schema as the table or view for which the alias was created. If
the table is not qualified and does not exist at the time the alias is created: </p>
<ul>
<li>If the value of the CURRENT SCHEMA special register is *LIBL, the alias
will be created in the current library (*CURLIB).</li>
<li>Otherwise, the alias will be created in the current schema.</li></ul>
<p>If the alias name is not a valid system name, DB2 UDB for iSeries will generate
a system name. For information on the rules for generating a name, see <a href="rbafzmsthctabl.htm#namrul">Rules for Table Name Generation</a>.</p>
</dd>
<dt class="bold">FOR <var class="pv">table-name</var> <span class="base">or</span> <var class="pv">view-name</var> </dt><a id="idx1595" name="idx1595"></a><a id="idx1596" name="idx1596"></a><a id="idx1597" name="idx1597"></a>
<dd>Identifies the table or view at the current server for which the alias
is to be defined. An alias name cannot be specified (an alias cannot refer
to another alias).
<p>The <var class="pv">table-name</var> or <var class="pv">view-name</var> need not
identify a table or view that exists at the time the alias is created. If
the table or view does not exist when the alias is created, a warning is returned.
If the table or view does not exist when the alias is used, an error is returned.</p>
<p>If SQL names were specified and the <var class="pv">table-name</var> or <var class="pv">view-name</var> was not qualified, then the qualifier is the implicit qualifier. For
more information, see <a href="rbafzmstch2nam.htm#ch2nam">Naming conventions</a>.</p>
<p>If system names
were specified and the <var class="pv">table-name</var> or <var class="pv">view-name</var> is not qualified
and does not exist when the alias is created, the <var class="pv">table-name</var> or <var class="pv">view-name</var> is qualified by the library in which the alias is created.</p>
</dd>
<dt class="bold"><var class="pv">partition-name</var></dt>
<dd>Identifies a partition of a partitioned table.
<p>If a partition is
specified, the alias cannot be used in SQL schema statements. If a partition
is not specified, all partitions in the table are included in the alias.</p>
</dd>
<dt class="bold"><var class="pv">member-name</var></dt>
<dd>Identifies a member of a database file.
<p>If a member is specified,
the alias cannot be used in SQL schema statements. If a member name is not
specified, *FIRST is used.</p>
</dd>
</dl>
<a name="wq1173"></a>
<h3 id="wq1173"><a href="rbafzmst02.htm#ToC_842">Notes</a></h3>
<p>The Override Database File (OVRDBF) CL command allows the database manager
to process individual members of a database file. Creating an alias over a
partition of a table or member of a database file, however, is easier and
performs better by eliminating the need to perform the override.</p>
<p>An alias can be defined to reference either the system name or SQL name.
However, since system names are generated during create processing, it is
recommended that the SQL name be specified.</p>
<p><span class="bold">Alias attributes:</span> An alias is created as a special
form of a DDM file.</p>
<p>An alias created over a distributed table is only created on the current
server. For more information about distributed tables, see the <a href="../dbmult/rzaf3kickoff.htm">DB2&reg; Multisystem</a> book.</p>
<p><span class="bold">Alias ownership:</span> If SQL names were specified:</p>
<ul>
<li>If a user profile with the same name as the schema into which the alias
is created exists, the <span class="italic">owner</span> of the alias is that
user profile.</li>
<li>Otherwise, the <span class="italic">owner</span> of the alias is the user
profile or group user profile of the job executing the statement.</li></ul>
<p>If system names were specified, the <span class="italic">owner</span> of the
alias is the user profile or group user profile of the job executing the statement.</p>
<p><span class="bold">Alias authority:</span> If SQL names are used, aliases are
created with the system authority of *EXCLUDE on *PUBLIC. If system names
are used, aliases are created with the authority to *PUBLIC as determined
by the create authority (CRTAUT) parameter of the schema.</p>
<p>If the owner of the alias is a member of a group profile (GRPPRF keyword)
and group authority is specified (GRPAUT keyword), that group profile will
also have authority to the alias.</p>
<p><span class="bold">Syntax alternatives:</span> The following keywords are synonyms
supported for compatibility to prior releases. These keywords are non-standard
and should not be used:</p>
<ul>
<li>The keyword SYNONYM can be used as a synonym for ALIAS.</li></ul>
<a name="wq1174"></a>
<h3 id="wq1174"><a href="rbafzmst02.htm#ToC_843">Examples</a></h3>
<p><span class="italic">Example 1:</span> Create an alias named CURRENT_PROJECTS
for the PROJECT table. </p>
<pre class="xmp"><span class="bold">CREATE ALIAS</span> CURRENT_PROJECTS
<span class="bold">FOR</span> PROJECT<span class="bold"></span></pre>
<p><span class="italic">Example 2:</span> Create an alias named SALES_JANUARY
on the JANUARY partition of the SALES table. The sales table has 12 partitions
(one for each month of the year). </p>
<pre class="xmp"><span class="bold">CREATE ALIAS</span> SALES_JANUARY
<span class="bold">FOR</span> SALES<span class="bold">(</span>JANUARY<span class="bold">)</span></pre>
<p><a id="idx1598" name="idx1598"></a><a id="idx1599" name="idx1599"></a></p>
<hr /><br />
[ <a href="#Top_Of_Page">Top of Page</a> | <a href="rbafzmstcon2t.htm">Previous Page</a> | <a href="rbafzmstcrtudt.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>