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

248 lines
13 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="Insert information into a table" />
<meta name="DC.Relation" scheme="URI" content="rzatcgetstartsql.htm" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="rzatcinsertsql" />
<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>Insert information into a table</title>
</head>
<body id="rzatcinsertsql"><a name="rzatcinsertsql"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Insert information into a table</h1>
<div><div class="section">After you create a table, you can insert, or add, information (data)
into it by using the SQL INSERT statement.</div>
<ol><li class="stepexpand"><span>On the Enter SQL Statements display, type <tt>INSERT</tt> and press
F4 (Prompt). The Specify INSERT Statement display is shown.</span> <div class="p"><pre class="screen"> Specify INSERT Statement
Type choices, press Enter.
INTO table . . . . . . . <strong>INVENTORY_LIST</strong>______ Name, F4 for list
Collection . . . . . . <strong>SAMPLECOLL</strong>__ Name, F4 for list
Select columns to insert
INTO . . . . . . . . . Y Y=Yes, N=No
Insertion method . . . . 1 1=Input VALUES
2=Subselect
Type choices, press Enter.
WITH isolation level . . 1 1=Current level, 2=NC (NONE)
3=UR (CHG), 4=CS, 5=RS (ALL)
6=RR
F3=Exit F4=Prompt F5=Refresh F12=Cancel F20=Display full names
F21=Display statement</pre>
</div>
</li>
<li class="stepexpand"><span>Type the table name and schema name in the input fields as shown.</span></li>
<li class="stepexpand"><span>Change the <span class="uicontrol">Select columns to insert INTO</span> prompt
to <span class="uicontrol">Yes</span>.</span></li>
<li class="stepexpand"><span>Press Enter to see the display where the columns you want to insert
values into can be selected.</span> <div class="p"><pre class="screen"> Specify INSERT Statement
Type sequence numbers (1-999) to make selections, press Enter.
Seq Column Type Length Scale
1__ ITEM_NUMBER CHARACTER 6
2__ ITEM_NAME VARCHAR 20
3__ UNIT_COST DECIMAL 8 2
4__ QUANTITY_ON_HAND SMALLINT 4
___ LAST_ORDER_DATE DATE
___ ORDER_QUANTITY SMALLINT 4
Bottom
F3=Exit F5=Refresh F12=Cancel F19=Display system column names
F20=Display entire name F21=Display statement</pre>
</div>
<p>In this example,
insert into four of the columns. Allow the other columns have their default
value inserted. The sequence numbers on this display indicate the order that
the columns and values are listed in the INSERT statement. </p>
</li>
<li class="stepexpand"><span>Press Enter to show the display where values for the selected columns
can be typed.</span> <div class="p"><pre class="screen"> Specify INSERT Statement
Type values to insert, press Enter.
Column Value
ITEM_NUMBER <strong>'153047'</strong>_____________________________________________
ITEM_NAME <strong>'Pencils, red'</strong>_______________________________________
UNIT_COST <strong>10.00</strong>________________________________________________
QUANTITY_ON_HAND <strong>25</strong>___________________________________________________
Bottom
F3=Exit F5=Refresh F6=Insert line F10=Copy line F11=Display type
F12=Cancel F14=Delete line F15=Split line F24=More keys</pre>
</div>
<div class="note"><span class="notetitle">Note:</span> To
see the data type and length for each of the columns in the insert list, press
F11 (Display type). This shows a different view of the insert values display,
providing information about the column definition.</div>
</li>
<li class="stepexpand"><span>Type the values to be inserted for all of the columns and press
Enter. A row containing these values is added to the table. The values for
the columns that were not specified have a default value inserted. For LAST_ORDER_DATE
it is the null value because no default was provided and the column allows
the null value. For ORDER_QUANTITY it is 20, the value specified as the default
value on the CREATE TABLE statement.</span></li>
<li class="stepexpand"><span>Type the INSERT statement on the Enter SQL Statements display as:</span> <pre><strong>INSERT INTO</strong> SAMPLECOLL.INVENTORY_LIST
(ITEM_NUMBER,
ITEM_NAME,
UNIT_COST,
QUANTITY_ON_HAND)
<strong>VALUES</strong> (153047 ,
Pencils,red ,
10.00,
25)</pre>
</li>
<li class="stepexpand"><span>To add the next row to the table, press F9 (Retrieve) on the Enter
SQL Statements display. This copies the previous INSERT statement to the typing
area. You can either type over the values from the previous INSERT statement
or press F4 (Prompt) to use the Interactive SQL displays to enter data.</span></li>
<li class="stepexpand"><span>Continue using the INSERT statement to add the following rows to
the table. </span></li>
</ol>
<div class="section">Values not shown in the chart below should not be inserted so that
the default is used. In the INSERT statement column list, specify
only the column names for which you want to insert a value. For example, to
insert the third row, specify only ITEM_NUMBER and UNIT_COST for the column
names and only the two values for these columns in the VALUES list.
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" frame="border" border="1" rules="all"><thead align="left"><tr><th valign="top" width="22.10796915167095%" id="d0e98">ITEM_NUMBER </th>
<th valign="top" width="24.164524421593832%" id="d0e100">ITEM_NAME </th>
<th valign="top" width="24.164524421593832%" id="d0e102">UNIT_COST </th>
<th valign="top" width="29.562982005141386%" id="d0e104">QUANTITY_ON_HAND</th>
</tr>
</thead>
<tbody><tr><td valign="top" width="22.10796915167095%" headers="d0e98 ">153047 </td>
<td valign="top" width="24.164524421593832%" headers="d0e100 ">Pencils, red </td>
<td valign="top" width="24.164524421593832%" headers="d0e102 ">10.00</td>
<td valign="top" width="29.562982005141386%" headers="d0e104 ">25</td>
</tr>
<tr><td valign="top" width="22.10796915167095%" headers="d0e98 ">229740</td>
<td valign="top" width="24.164524421593832%" headers="d0e100 ">Lined tablets </td>
<td valign="top" width="24.164524421593832%" headers="d0e102 ">1.50</td>
<td valign="top" width="29.562982005141386%" headers="d0e104 ">120 </td>
</tr>
<tr><td valign="top" width="22.10796915167095%" headers="d0e98 ">544931 </td>
<td valign="top" width="24.164524421593832%" headers="d0e100 ">&nbsp;</td>
<td valign="top" width="24.164524421593832%" headers="d0e102 ">5.00</td>
<td valign="top" width="29.562982005141386%" headers="d0e104 ">&nbsp;</td>
</tr>
<tr><td valign="top" width="22.10796915167095%" headers="d0e98 ">303476</td>
<td valign="top" width="24.164524421593832%" headers="d0e100 ">Paper clips </td>
<td valign="top" width="24.164524421593832%" headers="d0e102 ">2.00</td>
<td valign="top" width="29.562982005141386%" headers="d0e104 ">100</td>
</tr>
<tr><td valign="top" width="22.10796915167095%" headers="d0e98 ">559343 </td>
<td valign="top" width="24.164524421593832%" headers="d0e100 ">Envelopes, legal</td>
<td valign="top" width="24.164524421593832%" headers="d0e102 ">3.00 </td>
<td valign="top" width="29.562982005141386%" headers="d0e104 ">500</td>
</tr>
<tr><td valign="top" width="22.10796915167095%" headers="d0e98 ">291124 </td>
<td valign="top" width="24.164524421593832%" headers="d0e100 ">Envelopes, standard</td>
<td valign="top" width="24.164524421593832%" headers="d0e102 ">&nbsp;</td>
<td valign="top" width="29.562982005141386%" headers="d0e104 ">&nbsp;</td>
</tr>
<tr><td valign="top" width="22.10796915167095%" headers="d0e98 ">775298 </td>
<td valign="top" width="24.164524421593832%" headers="d0e100 ">Chairs, secretary</td>
<td valign="top" width="24.164524421593832%" headers="d0e102 ">225.00</td>
<td valign="top" width="29.562982005141386%" headers="d0e104 ">6 </td>
</tr>
<tr><td valign="top" width="22.10796915167095%" headers="d0e98 ">073956</td>
<td valign="top" width="24.164524421593832%" headers="d0e100 ">Pens, black </td>
<td valign="top" width="24.164524421593832%" headers="d0e102 ">20.00</td>
<td valign="top" width="29.562982005141386%" headers="d0e104 ">25</td>
</tr>
</tbody>
</table>
</div>
<div class="p">Add the following rows to the SAMPLECOLL.SUPPLIERS table.
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" frame="border" border="1" rules="all"><thead align="left"><tr><th valign="top" width="35.23489932885906%" id="d0e184">SUPPLIER_NUMBER </th>
<th valign="top" width="32.21476510067114%" id="d0e186">ITEM_NUMBER </th>
<th valign="top" width="32.5503355704698%" id="d0e188">SUPPLIER_COST</th>
</tr>
</thead>
<tbody><tr><td valign="top" width="35.23489932885906%" headers="d0e184 ">1234 </td>
<td valign="top" width="32.21476510067114%" headers="d0e186 ">153047 </td>
<td valign="top" width="32.5503355704698%" headers="d0e188 ">10.00</td>
</tr>
<tr><td valign="top" width="35.23489932885906%" headers="d0e184 ">1234 </td>
<td valign="top" width="32.21476510067114%" headers="d0e186 ">229740</td>
<td valign="top" width="32.5503355704698%" headers="d0e188 ">1.00 </td>
</tr>
<tr><td valign="top" width="35.23489932885906%" headers="d0e184 ">1234</td>
<td valign="top" width="32.21476510067114%" headers="d0e186 ">303476 </td>
<td valign="top" width="32.5503355704698%" headers="d0e188 ">3.00</td>
</tr>
<tr><td valign="top" width="35.23489932885906%" headers="d0e184 ">9988</td>
<td valign="top" width="32.21476510067114%" headers="d0e186 ">153047</td>
<td valign="top" width="32.5503355704698%" headers="d0e188 ">8.00</td>
</tr>
<tr><td valign="top" width="35.23489932885906%" headers="d0e184 ">9988 </td>
<td valign="top" width="32.21476510067114%" headers="d0e186 ">559343</td>
<td valign="top" width="32.5503355704698%" headers="d0e188 ">3.00</td>
</tr>
<tr><td valign="top" width="35.23489932885906%" headers="d0e184 ">2424 </td>
<td valign="top" width="32.21476510067114%" headers="d0e186 ">153047</td>
<td valign="top" width="32.5503355704698%" headers="d0e188 ">9.00 </td>
</tr>
<tr><td valign="top" width="35.23489932885906%" headers="d0e184 ">2424</td>
<td valign="top" width="32.21476510067114%" headers="d0e186 ">303476 </td>
<td valign="top" width="32.5503355704698%" headers="d0e188 ">2.50 </td>
</tr>
<tr><td valign="top" width="35.23489932885906%" headers="d0e184 ">5546</td>
<td valign="top" width="32.21476510067114%" headers="d0e186 ">775298</td>
<td valign="top" width="32.5503355704698%" headers="d0e188 ">225.00</td>
</tr>
<tr><td valign="top" width="35.23489932885906%" headers="d0e184 ">3366 </td>
<td valign="top" width="32.21476510067114%" headers="d0e186 ">303476</td>
<td valign="top" width="32.5503355704698%" headers="d0e188 ">1.50</td>
</tr>
<tr><td valign="top" width="35.23489932885906%" headers="d0e184 ">3366</td>
<td valign="top" width="32.21476510067114%" headers="d0e186 ">073956 </td>
<td valign="top" width="32.5503355704698%" headers="d0e188 ">17.00</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>The sample schema now contains two tables with several rows
of data in each.</p>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="rzatcgetstartsql.htm" title="This topic describes how to create and work with schemas, tables, and views using SQL statements in interactive SQL.">Get started with SQL</a></div>
</div>
</div>
</body>
</html>