70 lines
4.1 KiB
HTML
70 lines
4.1 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="Delete information from a table" />
|
|
<meta name="DC.Relation" scheme="URI" content="rzatcgetstartsql.htm" />
|
|
<meta name="DC.Format" content="XHTML" />
|
|
<meta name="DC.Identifier" content="deletesql" />
|
|
<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>Delete information from a table</title>
|
|
</head>
|
|
<body id="deletesql"><a name="deletesql"><!-- --></a>
|
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
|
<h1 class="topictitle1">Delete information from a table</h1>
|
|
<div><div class="section">You can delete data from a table by using the SQL DELETE statement.
|
|
You can delete entire rows from a table when they no longer contain needed
|
|
information or you can use the WHERE clause with the DELETE statement to identify
|
|
rows to be deleted during a single statement execution.<p>To remove all the
|
|
rows in a table that have the null value for the QUANTITY_ON_HAND column,
|
|
follow these steps:</p>
|
|
</div>
|
|
<ol><li class="stepexpand"><span>Enter the following statement on the Enter SQL Statements display:</span> <pre><strong>DELETE</strong>
|
|
<strong>FROM</strong> SAMPLECOLL.INVENTORY_LIST
|
|
<strong>WHERE</strong> QUANTITY_ON_HAND IS NULL</pre>
|
|
To check a column for the
|
|
null value, the IS NULL comparison is used.<p>This <a href="codedisclaimer.htm">disclaimer information</a> pertains to code examples.</p>
|
|
</li>
|
|
<li class="stepexpand"><span>After the delete operation is completed, run another
|
|
SELECT statement. This results in the following table:</span> <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
|
|
303476 Paper clips 2.00 100 05/30/94 50
|
|
559343 Envelopes, legal 3.00 500 - 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>
|
|
</li>
|
|
</ol>
|
|
<div class="section">The rows with a null value for QUANTITY_ON_HAND were deleted.</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> |