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

83 lines
4.9 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="description, alias" />
<title>Aliases</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="ch2alias"></a>
<h2 id="ch2alias"><a href="rbafzmst02.htm#ToC_94">Aliases</a></h2><a id="idx300" name="idx300"></a>
<p>An <span class="italic">alias</span> can be thought of as an alternative name
for a table, partition of a table, view, or member of a database file. A table
or view in an SQL statement can be referenced by its name or by an alias.
An alias can only refer to a table, partition of a table, view, or database
file member within the same relational database.</p>
<p>An alias can be used wherever a table or view name can be used, except:</p>
<ul>
<li>Do not use an alias name where a new table or view name is expected, such
as in the CREATE TABLE or CREATE VIEW statements. For example, if an alias
name of PERSONNEL is created, then a subsequent statement such as CREATE TABLE
PERSONNEL will cause an error.</li>
<li>An alias that refers to an individual partition of a table or member of
a database file can only be used in a select statement, CREATE INDEX, DELETE,
INSERT, SELECT INTO, SET variable, UPDATE, or VALUES INTO statement.</li></ul>
<p>Aliases can also help avoid using file overrides. Not only does an alias
perform better than an override, but an alias is also a permanent object that
only need be created once.</p>
<p>An alias can be created even though the object that the alias refers to
does not exist. However, the object must exist when a statement that references
the alias is executed. A warning is returned if the object does not exist
when the alias is created. An alias cannot refer to another alias. An alias
can only refer to a table, partition of a table, view, or database file member
within the same relational database.</p>
<p>The option of referring to a table, partition of a table, view, or database
file member by an alias name is not explicitly shown in the syntax diagrams
or mentioned in the description of the SQL statements.</p>
<p>A new alias cannot have the same fully-qualified name as an existing table,
view, index, file, or alias.</p>
<p>The effect of using an alias in an SQL statement is similar to that of
text substitution. The alias, which must be defined before the SQL statement
is executed, is replaced by the qualified base table, partition of a table,
view, or database file member name. For example, if PBIRD.SALES is an alias
for DSPN014.DIST4_SALES_148, then at statement run time:</p>
<pre class="xmp"> <span class="bold">SELECT * FROM</span> PBIRD.SALES
</pre>
<p>effectively becomes</p>
<pre class="xmp"> <span class="bold">SELECT * FROM</span> DSPN014.DIST4_SALES_148
</pre>
<p>The effect of dropping an alias and recreating it to refer to another table
depends on the statement that references the alias. </p>
<ul>
<li>SQL Data or SQL Data Change statements that refer to that alias will be
implicitly rebound when they are next run.</li>
<li>If a CREATE VIEW or CREATE INDEX statement refers to an alias, dropping
and re-creating the alias has no effect on the view or index.</li></ul>
<p>For syntax toleration of existing DB2 UDB for z/OS applications, SYNONYM can be
used in place of ALIAS in the CREATE ALIAS and DROP ALIAS statements.</p>
<hr /><br />
[ <a href="#Top_Of_Page">Top of Page</a> | <a href="rbafzmstch2nam.htm">Previous Page</a> | <a href="rbafzmstch2auth.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>