170 lines
8.3 KiB
HTML
170 lines
8.3 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="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="Change information in a table" />
|
|||
|
<meta name="DC.Relation" scheme="URI" content="rzatcgetstartsql.htm" />
|
|||
|
<meta name="DC.Relation" scheme="URI" content="../sqlp/rbafykickoff.htm" />
|
|||
|
<meta name="DC.Format" content="XHTML" />
|
|||
|
<meta name="DC.Identifier" content="rzatcchgtblsql" />
|
|||
|
<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>Change information in a table</title>
|
|||
|
</head>
|
|||
|
<body id="rzatcchgtblsql"><a name="rzatcchgtblsql"><!-- --></a>
|
|||
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
|||
|
<h1 class="topictitle1">Change information in a table</h1>
|
|||
|
<div><div class="section">You can use the SQL UPDATE statement to change the data values in
|
|||
|
some or all of the columns of a table. <p>If you want to limit the number
|
|||
|
of rows being changed during a single statement execution, use the WHERE clause
|
|||
|
with the UPDATE statement. If you do not specify the WHERE clause, all of
|
|||
|
the rows in the specified table are changed. However, if you use the WHERE
|
|||
|
clause, the system changes only the rows satisfying the conditions that you
|
|||
|
specify.</p>
|
|||
|
<p>Suppose you want to use interactive SQL and are placing an
|
|||
|
order for more paper clips today.</p>
|
|||
|
</div>
|
|||
|
<ol><li class="stepexpand"><span>To update the LAST_ORDER_DATE and ORDER_QUANTITY for item number
|
|||
|
303476, type <tt>UPDATE</tt> and press F4 (Prompt). The Specify UPDATE Statement
|
|||
|
display is shown.</span> <div class="p"><pre class="screen"> Specify UPDATE Statement
|
|||
|
|
|||
|
Type choices, press Enter.
|
|||
|
|
|||
|
Table . . . . . . . . <strong>INVENTORY_LIST</strong>______ Name, F4 for list
|
|||
|
Collection . . . . . <strong>SAMPLECOLL</strong>__ Name, F4 for list
|
|||
|
|
|||
|
Correlation . . . . . ____________________ Name
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
F3=Exit F4=Prompt F5=Refresh F12=Cancel F20=Display full names
|
|||
|
F21=Display statement</pre>
|
|||
|
</div>
|
|||
|
</li>
|
|||
|
<li class="stepexpand"><span><img src="./delta.gif" alt="Start of change" />Enter the table name and schema name, as shown
|
|||
|
in the previous panel. <img src="./deltaend.gif" alt="End of change" /></span></li>
|
|||
|
<li class="stepexpand"><span>Press Enter. The display is shown again with the list of columns
|
|||
|
in the table.</span> <div class="p"><pre class="screen"> Specify UPDATE Statement
|
|||
|
|
|||
|
Type choices, press Enter.
|
|||
|
|
|||
|
Table . . . . . . . . INVENTORY_LIST______ Name, F4 for list
|
|||
|
Collection . . . . . SAMPLECOLL__ Name, F4 for list
|
|||
|
|
|||
|
Correlation . . . . . ____________________ Name
|
|||
|
|
|||
|
|
|||
|
Type information, press Enter.
|
|||
|
|
|||
|
Column Value
|
|||
|
ITEM_NUMBER _____________________________________________________
|
|||
|
ITEM_NAME _____________________________________________________
|
|||
|
UNIT_COST _____________________________________________________
|
|||
|
QUANTITY_ON_HAND _____________________________________________________
|
|||
|
LAST_ORDER_DATE <strong>CURRENT DATE</strong>_________________________________________
|
|||
|
ORDER_QUANTITY <strong>50</strong>___________________________________________________
|
|||
|
|
|||
|
Bottom
|
|||
|
F3=Exit F4=Prompt F5=Refresh F6=Insert line F10=Copy line
|
|||
|
F11=Display type F12=Cancel F14=Delete line F24=More keys</pre>
|
|||
|
</div>
|
|||
|
</li>
|
|||
|
<li class="stepexpand"><span>Specify <kbd class="userinput">CURRENT DATE</kbd> in the <span class="uicontrol">LAST_ORDER_DATE</span> field
|
|||
|
to change the value to today's date.</span></li>
|
|||
|
<li class="stepexpand"><span>Enter the updated values as shown.</span></li>
|
|||
|
<li class="stepexpand"><span>Press Enter to see the display on which the WHERE condition can
|
|||
|
be specified. If a WHERE condition is not specified, all the rows in the table
|
|||
|
are updated using the values from the previous display.</span> <div class="p"><pre class="screen"> Specify UPDATE Statement
|
|||
|
|
|||
|
Type WHERE conditions, press Enter. Press F4 for a list.
|
|||
|
<strong> ITEM_NUMBER = '303476'</strong>________________________________________________
|
|||
|
______________________________________________________________________
|
|||
|
|
|||
|
|
|||
|
|
|||
|
Bottom
|
|||
|
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 F6=Insert line F9=Specify subquery
|
|||
|
F10=Copy line F12=Cancel F14=Delete line F15=Split line F24=More keys</pre>
|
|||
|
</div>
|
|||
|
</li>
|
|||
|
<li class="stepexpand"><span>Enter <kbd class="userinput">ITEM_NUMBER =’303476’</kbd> in the WHERE
|
|||
|
condition field. </span></li>
|
|||
|
<li class="stepexpand"><span>Press Enter to perform the update on the table. A message indicates
|
|||
|
that the function is complete.</span></li>
|
|||
|
</ol>
|
|||
|
<div class="section">Running a SELECT statement to get all the rows from the table (SELECT
|
|||
|
* FROM SAMPLECOLL.INVENTORY_LIST), returns the following result:<div class="p"><pre class="screen"> Display Data
|
|||
|
Data width . . . . . . : 71
|
|||
|
Position to line . . . . . Shift to column . . . . . .
|
|||
|
....+....1....+....2....+....3....+....4....+....5....+....6....+....7.
|
|||
|
ITEM ITEM UNIT QUANTITY LAST NUMBER
|
|||
|
NUMBER NAME COST ON ORDER ORDERED
|
|||
|
HAND DATE
|
|||
|
153047 Pencils, red 10.00 25 - 20
|
|||
|
229740 Lined tablets 1.50 120 - 20
|
|||
|
544931 ***UNKNOWN*** 5.00 - - 20
|
|||
|
303476 Paper clips 2.00 100 05/30/94 50
|
|||
|
559343 Envelopes, legal 3.00 500 - 20
|
|||
|
291124 Envelopes, standard .00 - - 20
|
|||
|
775298 Chairs, secretary 225.00 6 - 20
|
|||
|
073956 Pens, black 20.00 25 - 20
|
|||
|
******** End of data ********
|
|||
|
Bottom
|
|||
|
F3=Exit F12=Cancel F19=Left F20=Right F21=Split</pre>
|
|||
|
</div>
|
|||
|
<p>Only
|
|||
|
the entry for <em>Paper clips</em> was changed. The LAST_ORDER_DATE was changed
|
|||
|
to be the current date. This date is always the date the update is run. The
|
|||
|
NUMBER_ORDERED shows its updated value.</p>
|
|||
|
</div>
|
|||
|
<div class="section">This statement can be typed on the Enter SQL Statements display as:<pre><strong>UPDATE</strong> SAMPLECOLL.INVENTORY_LIST
|
|||
|
<strong>SET</strong> LAST_ORDER_DATE = CURRENT DATE,
|
|||
|
ORDER_QUANTITY = 50
|
|||
|
<strong>WHERE</strong> ITEM_NUMBER = ’303476’</pre>
|
|||
|
</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 class="relinfo"><strong>Related information</strong><br />
|
|||
|
<div><a href="../sqlp/rbafykickoff.htm">SQL Programming</a></div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
</body>
|
|||
|
</html>
|