ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzatc_5.4.0.1/rzatccrttable.htm

126 lines
8.0 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 lang="en-us" xml:lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="copyright" content="(C) Copyright IBM Corporation 2005" />
<meta name="DC.rights.owner" content="(C) Copyright IBM Corporation 2005" />
<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="task" />
<meta name="DC.Title" content="Create a table and define a column" />
<meta name="DC.Relation" scheme="URI" content="rzatcgetstartinav.htm" />
<meta name="DC.Relation" scheme="URI" content="rzatcdefinecol.htm" />
<meta name="DC.Relation" scheme="URI" content="rzatcsupplier.htm" />
<meta name="DC.Relation" scheme="URI" content="rzatccopycol.htm" />
<meta name="DC.Relation" scheme="URI" content="rzatcinsertinfo.htm" />
<meta name="DC.Relation" scheme="URI" content="rzatcviewcontents.htm" />
<meta name="DC.Relation" scheme="URI" content="rzatcchangeinfo.htm" />
<meta name="DC.Relation" scheme="URI" content="rzatcdelinfo.htm" />
<meta name="DC.Relation" scheme="URI" content="rzatccopytable.htm" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="rzatccrttable" />
<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 a table and define a column</title>
</head>
<body id="rzatccrttable"><a name="rzatccrttable"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Create a table and define a column</h1>
<div><div class="section">A table is a basic database object that is used to store information.
After you have created a table, you can define columns, create indexes, and
add triggers and constraints by using the Table Properties window. <p>When
you are creating a table, you need to understand the concepts of null value
and default value. A null value indicates the absence of a column value for
a row. It is not the same as a value of zero or all blanks. It means <em>unknown</em>.
It is not equal to any value, not even to other null values. If a column does
not allow the null value, a value must be assigned to the column. This value
is either a default value or a user supplied value.</p>
<p>If no value is specified
for a column when a row is added to a table, the row is assigned a default
value. If the column is not assigned a specific default value, the column
uses the system default value.</p>
<p>This example shows you how to create
a table to maintain information about the current inventory of a business.
It has information about the items kept in the inventory, their cost, quantity
currently on hand, the last order date, and the number last ordered. The item
number is a required value. It cannot be null. The item name, quantity on
hand, and order quantity have user-supplied default values. The last order
date and quantity allow the null value.</p>
<p>To create a table, follow these
steps:</p>
</div>
<ol><li><span>In the <span class="keyword">iSeries™ Navigator</span> window,
expand the system that you want to use. </span></li>
<li><span>Expand <span class="uicontrol">Databases</span> and the database that you
want to work with.</span></li>
<li><span>Expand <span class="uicontrol">Schemas</span>.</span></li>
<li><span>Right-click <span class="uicontrol">SAMPLELIB</span> and select <span class="uicontrol">New</span>.</span></li>
<li><span>Select <span class="menucascade"><span class="uicontrol">Table</span> &gt; <span class="uicontrol">Table</span></span>.</span></li>
<li><span>On the New Table window, specify INVENTORY_LIST as the table name.</span></li>
<li><span>Select <span class="uicontrol">SAMPLELIB</span> in the <span class="uicontrol">Schema</span> field.</span></li>
<li><span>Select <span class="uicontrol">System-generated</span> in the <span class="uicontrol">System
table name</span> field.</span></li>
<li><span>Specify a description in the <span class="uicontrol">Text</span> field
(optional). <br /><img src="rzatc002.gif" alt="screen capture of new table window" /><br /></span></li>
<li><span>Next, define a column for the new table. Click the <span class="uicontrol">Columns</span> tab.</span></li>
<li><span>Click the <span class="uicontrol">Add</span> button.</span></li>
<li><span>Enter ITEM_NUMBER in the <span class="uicontrol">Column name</span> field.</span></li>
<li><span>You can specify a short name in the <span class="uicontrol">Short column name</span> field.
If you do not specify a short name, the system automatically generates a name.
If the column name is 10 characters or less, then the short name is the same
as the column name. You can perform queries by using either column name. Just
leave this space as the default, <span class="uicontrol">System-generated</span>,
for now.</span></li>
<li><span>Select <span class="uicontrol">CHARACTER</span> as the Data type.</span></li>
<li><span>Specify a length of 6 for this column. For data types where the
size is predetermined, the size is filled in and you cannot change the value.</span></li>
<li><span>Leave the <span class="uicontrol">Encoding</span> option as the default, <span class="uicontrol">Data
type default</span>.</span></li>
<li><span>You can specify a description for the column in the <span class="uicontrol">Text</span> field.
This step is optional.</span></li>
<li><span>Enter a column heading in the <span class="uicontrol">Heading</span> fields.
The heading is the label that appears at the top of the column
for displaying or printing. You are limited to 60 characters, 20 per line.</span></li>
<li><span>Deselect the <span class="uicontrol">Nullable</span> option. This ensures
that a value must be placed in this column in order for the row insert to
be successful.</span></li>
<li><span>In the <span class="uicontrol">Default value</span> field, enter <kbd class="userinput">0</kbd>. </span></li>
<li><span>Click <span class="uicontrol">OK</span> to create the table.<br /><img src="rzatc003.gif" alt="screen capture of new column window" /><br /></span></li>
</ol>
<div class="section"><p>The new table INVENTORY_LIST appears. </p>
</div>
</div>
<div>
<ul class="ullinks">
<li class="ulchildlink"><strong><a href="rzatcdefinecol.htm">Define additional columns on a table</a></strong><br />
</li>
<li class="ulchildlink"><strong><a href="rzatcsupplier.htm">Create the supplier table (SUPPLIERS)</a></strong><br />
</li>
<li class="ulchildlink"><strong><a href="rzatccopycol.htm">Copy column definitions</a></strong><br />
</li>
<li class="ulchildlink"><strong><a href="rzatcinsertinfo.htm">Insert information into a table</a></strong><br />
</li>
<li class="ulchildlink"><strong><a href="rzatcviewcontents.htm">View the contents of a table</a></strong><br />
</li>
<li class="ulchildlink"><strong><a href="rzatcchangeinfo.htm">Change information in a table</a></strong><br />
</li>
<li class="ulchildlink"><strong><a href="rzatcdelinfo.htm">Delete information from a table</a></strong><br />
</li>
<li class="ulchildlink"><strong><a href="rzatccopytable.htm">Copy and move a table</a></strong><br />
</li>
</ul>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="rzatcgetstartinav.htm" title="This tutorial describes how to create and work with schemas, tables, and views using iSeries Navigator.">Get started with iSeries Navigator</a></div>
</div>
</div>
</body>
</html>