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

87 lines
5.4 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 a table" />
<meta name="abstract" content="A table can be visualized as a two-dimensional arrangement of data consisting of rows and columns." />
<meta name="description" content="A table can be visualized as a two-dimensional arrangement of data consisting of rows and columns." />
<meta name="DC.subject" content="CREATE TABLE statement, statements, CREATE TABLE statement, examples" />
<meta name="keywords" content="CREATE TABLE statement, statements, CREATE TABLE statement, examples" />
<meta name="DC.Relation" scheme="URI" content="rbafysqltech.htm" />
<meta name="DC.Relation" scheme="URI" content="rbafyaddconstraints.htm" />
<meta name="DC.Relation" scheme="URI" content="rbafyrefinteg.htm" />
<meta name="DC.Relation" scheme="URI" content="rbafyremovecon.htm" />
<meta name="DC.Relation" scheme="URI" content="rbafyrfcheck.htm" />
<meta name="DC.Relation" scheme="URI" content="../db2/rbafzmstch2data.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="rbafysqlpctablecreate" />
<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</title>
</head>
<body id="rbafysqlpctablecreate"><a name="rbafysqlpctablecreate"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Create a table</h1>
<div><p>A table can be visualized as a two-dimensional arrangement of data
consisting of rows and columns.</p>
<div class="section"><p>The row is the horizontal part containing one or more columns.
The column is the vertical part containing one or more rows of data of one
data type. All data for a column must be of the same type. A table in SQL
is a keyed or non-keyed physical file.</p>
</div>
<div class="section"><p>Tables are created using the CREATE TABLE statement. The definition
must include its name and the names and attributes of its columns. The definition
may include other attributes of the table such as primary key.</p>
</div>
<div class="section"><p>Example: Given that you have administrative authority, create
a table named 'INVENTORY' with the following columns:</p>
<ul><li>Part number: Integer between 1 and 9999, and must not be
null</li>
<li>Description: Character of length 0 to 24</li>
<li>Quantity on hand: Integer between 0 and 100000</li>
</ul>
<p>The primary key is PARTNO.</p>
<pre><strong>CREATE TABLE</strong> INVENTORY
(PARTNO <strong>SMALLINT</strong> <strong>NOT NULL</strong>,
DESCR <strong>VARCHAR</strong>(24 ),
QONHAND <strong>INT</strong>,
<strong>PRIMARY KEY</strong>(PARTNO))</pre>
</div>
</div>
<div>
<ul class="ullinks">
<li class="ulchildlink"><strong><a href="rbafyaddconstraints.htm">Add and remove constraints to a table</a></strong><br />
Constraints can be added to a new table or to an existing
table. You can add a unique or primary key, a referential constraint, or a
check constraint, using the <em>ADD constraint</em> clause on the CREATE TABLE
or the ALTER TABLE statements.</li>
<li class="ulchildlink"><strong><a href="rbafyrefinteg.htm">Referential integrity and tables</a></strong><br />
Referential integrity is the condition of a set of tables in a database in which all references from one table to another are valid.</li>
<li class="ulchildlink"><strong><a href="rbafyremovecon.htm">Remove constraints</a></strong><br />
This example removes the primary key over column DEPTNO in table DEPARTMENT.</li>
<li class="ulchildlink"><strong><a href="rbafyrfcheck.htm">Check pending</a></strong><br />
Referential constraints and check constraints can be in a state known as check pending, where potential violations of the constraint exist.</li>
</ul>
<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/rbafzmstch2data.htm">Data types</a></div>
</div>
</div>
</body>
</html>