122 lines
7.9 KiB
HTML
122 lines
7.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="Sort sequence and views" />
|
|
<meta name="abstract" content="Views are created with the sort sequence that was in effect when the CREATE VIEW statement was run." />
|
|
<meta name="description" content="Views are created with the sort sequence that was in effect when the CREATE VIEW statement was run." />
|
|
<meta name="DC.subject" content="sort sequence, views, view, examples, sort sequence" />
|
|
<meta name="keywords" content="sort sequence, views, view, examples, sort sequence" />
|
|
<meta name="DC.Relation" scheme="URI" content="rbafyussisql.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="rbafyssviews" />
|
|
<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>Sort sequence and views</title>
|
|
</head>
|
|
<body id="rbafyssviews"><a name="rbafyssviews"><!-- --></a>
|
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
|
<h1 class="topictitle1">Sort sequence and views</h1>
|
|
<div><p>Views are created with the sort sequence that was in effect when
|
|
the CREATE VIEW statement was run.</p>
|
|
<div class="section"><p>When the view is referred to in a FROM clause, that sort sequence
|
|
is used for any character comparisons in the subselect of the CREATE VIEW.
|
|
At that time, an intermediate result table is produced from the view subselect.
|
|
The sort sequence in effect when the query is being run is then applied to
|
|
all the character and UCS-2 graphic comparisons (including those comparisons
|
|
involving implicit conversions to character, or UCS-2 or UTF-16 graphic) specified
|
|
in the query.</p>
|
|
</div>
|
|
<div class="section"><div class="p">The following SQL statements and tables show how views and sort
|
|
sequences work. View V1, used in the following examples, was created with
|
|
a shared-weight sort sequence of SRTSEQ(*LANGIDSHR) and LANGID(ENU). The CREATE
|
|
VIEW statement is as follows: <pre><strong>CREATE VIEW</strong> V1 <strong>AS</strong> <strong>SELECT</strong> *
|
|
<strong> FROM</strong> STAFF
|
|
<strong> WHERE</strong> JOB = 'MGR' <strong>AND</strong> ID < 100</pre>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="tablenoborder"><a name="rbafyssviews__viewtb"><!-- --></a><table cellpadding="4" cellspacing="0" summary="" id="rbafyssviews__viewtb" width="100%" frame="hsides" border="1" rules="all"><caption>Table 1. "SELECT * FROM V1"</caption><thead align="left"><tr><th align="left" valign="bottom" width="14.25925925925926%" id="d0e65">ID</th>
|
|
<th align="left" valign="bottom" width="14.25925925925926%" id="d0e67">NAME</th>
|
|
<th align="left" valign="bottom" width="14.25925925925926%" id="d0e69">DEPT</th>
|
|
<th align="left" valign="bottom" width="14.25925925925926%" id="d0e71">JOB</th>
|
|
<th align="left" valign="bottom" width="14.25925925925926%" id="d0e73">YEARS</th>
|
|
<th align="left" valign="bottom" width="14.25925925925926%" id="d0e75">SALARY</th>
|
|
<th align="left" valign="bottom" width="14.444444444444443%" id="d0e77">COMM</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr><td align="left" valign="top" width="14.25925925925926%" headers="d0e65 ">10</td>
|
|
<td align="left" valign="top" width="14.25925925925926%" headers="d0e67 ">Sanders</td>
|
|
<td align="left" valign="top" width="14.25925925925926%" headers="d0e69 ">20</td>
|
|
<td align="left" valign="top" width="14.25925925925926%" headers="d0e71 ">Mgr</td>
|
|
<td align="left" valign="top" width="14.25925925925926%" headers="d0e73 ">7</td>
|
|
<td align="left" valign="top" width="14.25925925925926%" headers="d0e75 ">18357.50</td>
|
|
<td align="left" valign="top" width="14.444444444444443%" headers="d0e77 ">0</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="14.25925925925926%" headers="d0e65 ">30</td>
|
|
<td align="left" valign="top" width="14.25925925925926%" headers="d0e67 ">Merenghi</td>
|
|
<td align="left" valign="top" width="14.25925925925926%" headers="d0e69 ">38</td>
|
|
<td align="left" valign="top" width="14.25925925925926%" headers="d0e71 ">MGR</td>
|
|
<td align="left" valign="top" width="14.25925925925926%" headers="d0e73 ">5</td>
|
|
<td align="left" valign="top" width="14.25925925925926%" headers="d0e75 ">17506.75</td>
|
|
<td align="left" valign="top" width="14.444444444444443%" headers="d0e77 ">0</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="14.25925925925926%" headers="d0e65 ">50</td>
|
|
<td align="left" valign="top" width="14.25925925925926%" headers="d0e67 ">Hanes</td>
|
|
<td align="left" valign="top" width="14.25925925925926%" headers="d0e69 ">15</td>
|
|
<td align="left" valign="top" width="14.25925925925926%" headers="d0e71 ">Mgr</td>
|
|
<td align="left" valign="top" width="14.25925925925926%" headers="d0e73 ">10</td>
|
|
<td align="left" valign="top" width="14.25925925925926%" headers="d0e75 ">20659.80</td>
|
|
<td align="left" valign="top" width="14.444444444444443%" headers="d0e77 ">0</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<div class="section"><p>Any queries run against view V1 are run against the result table
|
|
shown above. The query shown below is run with a sort sequence of SRTSEQ(*LANGIDUNQ)
|
|
and LANGID(ENU).</p>
|
|
</div>
|
|
|
|
<div class="tablenoborder"><a name="rbafyssviews__views1"><!-- --></a><table cellpadding="4" cellspacing="0" summary="" id="rbafyssviews__views1" width="100%" frame="hsides" border="1" rules="all"><caption>Table 2. "SELECT * FROM V1
|
|
WHERE JOB = 'MGR'" using the unique-weight sort sequence for ENU language
|
|
identifier</caption><thead align="left"><tr><th align="left" valign="bottom" width="14.25925925925926%" id="d0e141">ID</th>
|
|
<th align="left" valign="bottom" width="14.25925925925926%" id="d0e143">NAME</th>
|
|
<th align="left" valign="bottom" width="14.25925925925926%" id="d0e145">DEPT</th>
|
|
<th align="left" valign="bottom" width="14.25925925925926%" id="d0e147">JOB</th>
|
|
<th align="left" valign="bottom" width="14.25925925925926%" id="d0e149">YEARS</th>
|
|
<th align="left" valign="bottom" width="14.25925925925926%" id="d0e151">SALARY</th>
|
|
<th align="left" valign="bottom" width="14.444444444444443%" id="d0e153">COMM</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr><td align="left" valign="top" width="14.25925925925926%" headers="d0e141 ">30</td>
|
|
<td align="left" valign="top" width="14.25925925925926%" headers="d0e143 ">Merenghi</td>
|
|
<td align="left" valign="top" width="14.25925925925926%" headers="d0e145 ">38</td>
|
|
<td align="left" valign="top" width="14.25925925925926%" headers="d0e147 ">MGR</td>
|
|
<td align="left" valign="top" width="14.25925925925926%" headers="d0e149 ">5</td>
|
|
<td align="left" valign="top" width="14.25925925925926%" headers="d0e151 ">17506.75</td>
|
|
<td align="left" valign="top" width="14.444444444444443%" headers="d0e153 ">0</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="rbafyussisql.htm" title="A sort sequence defines how characters in a character set relate to each other when they are compared or ordered. Normalization allows you to compare strings that contain combining characters.">Sort sequences and normalization in SQL</a></div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html> |