ibm-information-center/dist/eclipse/plugins/i5OS.ic.sqlp_5.4.0.1/rbafycreatingalias.htm

75 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 lang="en-us" xml:lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<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="DC.Type" content="reference" />
<meta name="DC.Title" content="Create and use ALIAS names" />
<meta name="abstract" content="When you refer to an existing table or view, or to a physical file that consists of multiple members, you can avoid using file overrides by creating an alias. You can use the SQL CREATE ALIAS statement to do this." />
<meta name="description" content="When you refer to an existing table or view, or to a physical file that consists of multiple members, you can avoid using file overrides by creating an alias. You can use the SQL CREATE ALIAS statement to do this." />
<meta name="DC.subject" content="CREATE ALIAS statement, creating and using, statements, example, ALIAS names, creating, examples, CREATE ALIAS statement, INSERT statement, inserting into alias, DROP statement, dropping an alias" />
<meta name="keywords" content="CREATE ALIAS statement, creating and using, statements, example, ALIAS names, creating, examples, CREATE ALIAS statement, INSERT statement, inserting into alias, DROP statement, dropping an alias" />
<meta name="DC.Relation" scheme="URI" content="rbafysqltech.htm" />
<meta name="DC.Relation" scheme="URI" content="../db2/rbafzmsthcalias.htm" />
<meta name="copyright" content="(C) Copyright IBM Corporation 1998, 2006" />
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 1998, 2006" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="rbafycreatingalias" />
<meta name="DC.Language" 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. -->
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
<link rel="stylesheet" type="text/css" href="./ic.css" />
<title>Create and use ALIAS names</title>
</head>
<body id="rbafycreatingalias"><a name="rbafycreatingalias"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Create and use ALIAS names</h1>
<div><p>When you refer to an existing table or view, or to a physical file
that consists of multiple members, you can avoid using file overrides by creating
an alias. You can use the SQL CREATE ALIAS statement to do this.</p>
<div class="section"><p>You can create an alias for:</p>
<ul><li>A table or view</li>
<li>A <em>member</em> of a table</li>
</ul>
</div>
<div class="section"><p>A table alias defines a name for the file, including the specific
member name. You can use this alias name in an SQL statement in the same way
that a table name is used. Unlike overrides, alias names are objects that
exist until they are dropped. </p>
</div>
<div class="section"><p>For example, if there is a multiple member file MYLIB.MYFILE with
members MBR1 and MBR2, an alias can be created for the second member so that
SQL can easily refer to it. </p>
<pre><strong>CREATE ALIAS</strong> MYLIB.MYMBR2_ALIAS <strong>FOR</strong> MYLIB.MYFILE (MBR2)</pre>
</div>
<div class="section"><p>When alias MYLIB.MYMBR2_ALIAS is specified on the following insert
statement, the values are inserted into member MBR2 in MYLIB.MYFILE. </p>
<pre><strong>INSERT INTO</strong> MYLIB.MYMBR2_ALIAS <strong>VALUES</strong>('ABC', 6)</pre>
</div>
<div class="section"><p>Alias names can also be specified on DDL statements. Assume that
alias MYLIB.MYALIAS exists and is an alias for table MYLIB.MYTABLE. The following
DROP statement will drop table MYLIB.MYTABLE. </p>
<pre><strong>DROP TABLE</strong> MYLIB.MYALIAS</pre>
</div>
<div class="section"><p>If you really want to drop the alias name instead, specify the
ALIAS keyword on the drop statement: </p>
<pre><strong>DROP ALIAS</strong> MYLIB.MYALIAS</pre>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="rbafysqltech.htm" title="Data definition language (DDL) describes the portion of SQL that allows you to create, alter, and destroy database objects. These database objects include schemas, tables, views, sequences, catalogs, indexes, and aliases.">Data definition language (DDL)</a></div>
</div>
<div class="relinfo"><strong>Related information</strong><br />
<div><a href="../db2/rbafzmsthcalias.htm">CREATE ALIAS</a></div>
</div>
</div>
</body>
</html>