150 lines
8.7 KiB
HTML
150 lines
8.7 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="Allowable conversions" />
|
||
|
<meta name="abstract" content="When you change the data type of an existing column, the old and new attributes must be compatible." />
|
||
|
<meta name="description" content="When you change the data type of an existing column, the old and new attributes must be compatible." />
|
||
|
<meta name="DC.subject" content="ALTER TABLE statement, data types, allowable conversions" />
|
||
|
<meta name="keywords" content="ALTER TABLE statement, data types, allowable conversions" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="rbafyalter.htm" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="rbafychgcol.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="rbafyallowable" />
|
||
|
<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>Allowable conversions</title>
|
||
|
</head>
|
||
|
<body id="rbafyallowable"><a name="rbafyallowable"><!-- --></a>
|
||
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
||
|
<h1 class="topictitle1">Allowable conversions</h1>
|
||
|
<div><p>When you change the data type of an existing column, the old and
|
||
|
new attributes must be compatible. </p>
|
||
|
|
||
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" width="100%" frame="border" border="1" rules="all"><caption>Table 1. Allowable conversions</caption><thead align="left"><tr><th align="left" valign="bottom" width="50%" id="d0e34">FROM data type</th>
|
||
|
<th align="left" valign="bottom" width="50%" id="d0e36">TO data type</th>
|
||
|
</tr>
|
||
|
</thead>
|
||
|
<tbody><tr><td align="left" valign="top" width="50%" headers="d0e34 ">Decimal</td>
|
||
|
<td align="left" valign="top" width="50%" headers="d0e36 ">Numeric</td>
|
||
|
</tr>
|
||
|
<tr><td align="left" valign="top" width="50%" headers="d0e34 ">Decimal</td>
|
||
|
<td align="left" valign="top" width="50%" headers="d0e36 ">Bigint, Integer, Smallint</td>
|
||
|
</tr>
|
||
|
<tr><td align="left" valign="top" width="50%" headers="d0e34 ">Decimal</td>
|
||
|
<td align="left" valign="top" width="50%" headers="d0e36 ">Float</td>
|
||
|
</tr>
|
||
|
<tr><td align="left" valign="top" width="50%" headers="d0e34 ">Numeric</td>
|
||
|
<td align="left" valign="top" width="50%" headers="d0e36 ">Decimal</td>
|
||
|
</tr>
|
||
|
<tr><td align="left" valign="top" width="50%" headers="d0e34 ">Numeric</td>
|
||
|
<td align="left" valign="top" width="50%" headers="d0e36 ">Bigint, Integer, Smallint</td>
|
||
|
</tr>
|
||
|
<tr><td align="left" valign="top" width="50%" headers="d0e34 ">Numeric</td>
|
||
|
<td align="left" valign="top" width="50%" headers="d0e36 ">Float</td>
|
||
|
</tr>
|
||
|
<tr><td align="left" valign="top" width="50%" headers="d0e34 ">Bigint, Integer, Smallint</td>
|
||
|
<td align="left" valign="top" width="50%" headers="d0e36 ">Decimal</td>
|
||
|
</tr>
|
||
|
<tr><td align="left" valign="top" width="50%" headers="d0e34 ">Bigint, Integer, Smallint</td>
|
||
|
<td align="left" valign="top" width="50%" headers="d0e36 ">Numeric</td>
|
||
|
</tr>
|
||
|
<tr><td align="left" valign="top" width="50%" headers="d0e34 ">Bigint, Integer, Smallint</td>
|
||
|
<td align="left" valign="top" width="50%" headers="d0e36 ">Float</td>
|
||
|
</tr>
|
||
|
<tr><td align="left" valign="top" width="50%" headers="d0e34 ">Float</td>
|
||
|
<td align="left" valign="top" width="50%" headers="d0e36 ">Numeric</td>
|
||
|
</tr>
|
||
|
<tr><td align="left" valign="top" width="50%" headers="d0e34 ">Float</td>
|
||
|
<td align="left" valign="top" width="50%" headers="d0e36 ">Bigint, Integer, Smallint</td>
|
||
|
</tr>
|
||
|
<tr><td align="left" valign="top" width="50%" headers="d0e34 ">Character</td>
|
||
|
<td align="left" valign="top" width="50%" headers="d0e36 ">DBCS-open</td>
|
||
|
</tr>
|
||
|
<tr><td align="left" valign="top" width="50%" headers="d0e34 ">Character</td>
|
||
|
<td align="left" valign="top" width="50%" headers="d0e36 ">UCS-2 or UTF-16 graphic</td>
|
||
|
</tr>
|
||
|
<tr><td align="left" valign="top" width="50%" headers="d0e34 ">DBCS-open</td>
|
||
|
<td align="left" valign="top" width="50%" headers="d0e36 ">Character</td>
|
||
|
</tr>
|
||
|
<tr><td align="left" valign="top" width="50%" headers="d0e34 ">DBCS-open</td>
|
||
|
<td align="left" valign="top" width="50%" headers="d0e36 ">UCS-2 or UTF-16 graphic</td>
|
||
|
</tr>
|
||
|
<tr><td align="left" valign="top" width="50%" headers="d0e34 ">DBCS-either</td>
|
||
|
<td align="left" valign="top" width="50%" headers="d0e36 ">Character</td>
|
||
|
</tr>
|
||
|
<tr><td align="left" valign="top" width="50%" headers="d0e34 ">DBCS-either</td>
|
||
|
<td align="left" valign="top" width="50%" headers="d0e36 ">DBCS-open</td>
|
||
|
</tr>
|
||
|
<tr><td align="left" valign="top" width="50%" headers="d0e34 ">DBCS-either</td>
|
||
|
<td align="left" valign="top" width="50%" headers="d0e36 ">UCS-2 or UTF-16 graphic</td>
|
||
|
</tr>
|
||
|
<tr><td align="left" valign="top" width="50%" headers="d0e34 ">DBCS-only</td>
|
||
|
<td align="left" valign="top" width="50%" headers="d0e36 ">DBCS-open</td>
|
||
|
</tr>
|
||
|
<tr><td align="left" valign="top" width="50%" headers="d0e34 ">DBCS-only</td>
|
||
|
<td align="left" valign="top" width="50%" headers="d0e36 ">DBCS graphic</td>
|
||
|
</tr>
|
||
|
<tr><td align="left" valign="top" width="50%" headers="d0e34 ">DBCS-only</td>
|
||
|
<td align="left" valign="top" width="50%" headers="d0e36 ">UCS-2 or UTF-16 graphic</td>
|
||
|
</tr>
|
||
|
<tr><td align="left" valign="top" width="50%" headers="d0e34 ">DBCS graphic</td>
|
||
|
<td align="left" valign="top" width="50%" headers="d0e36 ">UCS-2 or UTF-16 graphic</td>
|
||
|
</tr>
|
||
|
<tr><td align="left" valign="top" width="50%" headers="d0e34 ">UCS-2 or UTF-16 graphic</td>
|
||
|
<td align="left" valign="top" width="50%" headers="d0e36 ">Character</td>
|
||
|
</tr>
|
||
|
<tr><td align="left" valign="top" width="50%" headers="d0e34 ">UCS-2 or UTF-16 graphic</td>
|
||
|
<td align="left" valign="top" width="50%" headers="d0e36 ">DBCS-open</td>
|
||
|
</tr>
|
||
|
<tr><td align="left" valign="top" width="50%" headers="d0e34 ">UCS-2 or UTF-16 graphic</td>
|
||
|
<td align="left" valign="top" width="50%" headers="d0e36 ">DBCS graphic</td>
|
||
|
</tr>
|
||
|
<tr><td align="left" valign="top" width="50%" headers="d0e34 ">distinct type</td>
|
||
|
<td align="left" valign="top" width="50%" headers="d0e36 ">source type</td>
|
||
|
</tr>
|
||
|
<tr><td align="left" valign="top" width="50%" headers="d0e34 ">source type</td>
|
||
|
<td align="left" valign="top" width="50%" headers="d0e36 ">distinct type</td>
|
||
|
</tr>
|
||
|
</tbody>
|
||
|
</table>
|
||
|
</div>
|
||
|
<div class="section"><p>When modifying an existing column, only the attributes that you
|
||
|
specify will be changed. All other attributes will remain unchanged. For
|
||
|
example, given the following table definition: </p>
|
||
|
<pre> <strong>CREATE TABLE</strong> EX1 (COL1 <strong>CHAR</strong>(10) <strong>DEFAULT</strong> 'COL1',
|
||
|
COL2 <strong>VARCHAR</strong>(20) <strong>ALLOCATE</strong>(10) <strong>CCSID</strong> 937,
|
||
|
COL3 <strong>VARGRAPHIC</strong>(20) <strong>ALLOCATE</strong>(10)
|
||
|
<strong>NOT NULL WITH DEFAULT</strong>)</pre>
|
||
|
</div>
|
||
|
<div class="section"><p>After running the following ALTER TABLE statement: </p>
|
||
|
<pre> <strong>ALTER TABLE</strong> EX1 <strong>ALTER COLUMN</strong> COL2 <strong>SET DATA TYPE VARCHAR</strong>(30)
|
||
|
<strong>ALTER COLUMN</strong> COL3 <strong>DROP NOT NULL</strong></pre>
|
||
|
</div>
|
||
|
<div class="section"><p>COL2 still has an allocated length of 10 and CCSID 937, and COL3
|
||
|
still has an allocated length of 10.</p>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div>
|
||
|
<div class="familylinks">
|
||
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="rbafyalter.htm" title="Changing the definition of a table allows you to add new columns, change an existing column definition (change its length, default value, and so on), drop existing columns, and add and remove constraints.">Change a table definition</a></div>
|
||
|
</div>
|
||
|
<div class="relref"><strong>Related reference</strong><br />
|
||
|
<div><a href="rbafychgcol.htm" title="You can change a column definition in a table using the ALTER COLUMN clause of the ALTER TABLE statement.">Change a column</a></div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</body>
|
||
|
</html>
|