64 lines
3.7 KiB
HTML
64 lines
3.7 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="Examples: UPDATE rules" />
|
|
<meta name="abstract" content="These examples illustrate the UPDATE rules." />
|
|
<meta name="description" content="These examples illustrate the UPDATE rules." />
|
|
<meta name="DC.subject" content="examples, UPDATE rules for constraints, constraint, UPDATE rules example" />
|
|
<meta name="keywords" content="examples, UPDATE rules for constraints, constraint, UPDATE rules example" />
|
|
<meta name="DC.Relation" scheme="URI" content="rbafyrfupdating.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="rbafyupdaterules" />
|
|
<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>Examples: UPDATE rules</title>
|
|
</head>
|
|
<body id="rbafyupdaterules"><a name="rbafyupdaterules"><!-- --></a>
|
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
|
<h1 class="topictitle1">Examples: UPDATE rules</h1>
|
|
<div><p>These examples illustrate the UPDATE rules.</p>
|
|
<div class="section"><p>For example, you cannot update a department number
|
|
from the department table if it is still responsible for some project, which
|
|
is described by a dependent row in the project table.</p>
|
|
</div>
|
|
<div class="section"><p>The following UPDATE fails because the PROJECT table has rows
|
|
that are dependent on DEPARTMENT.DEPTNO having a value of 'D01' (the row targeted
|
|
by the WHERE statement). If this UPDATE were allowed, the referential constraint
|
|
between the PROJECT and DEPARTMENT tables will be broken. </p>
|
|
<pre> <strong>UPDATE</strong> CORPDATA.DEPARTMENT
|
|
<strong>SET</strong> DEPTNO = 'D99'
|
|
<strong>WHERE</strong> DEPTNAME = 'DEVELOPMENT CENTER'</pre>
|
|
</div>
|
|
<div class="section"><p>The following statement fails because it violates the referential
|
|
constraint that exists between the primary key DEPTNO in DEPARTMENT and the
|
|
foreign key DEPTNO in PROJECT: </p>
|
|
<pre> <strong>UPDATE</strong> CORPDATA.PROJECT
|
|
<strong>SET</strong> DEPTNO = 'D00'
|
|
<strong>WHERE</strong> DEPTNO = 'D01';</pre>
|
|
</div>
|
|
<div class="section"><p>The statement attempts to change all department numbers of D01
|
|
to department number D00. Since D00 is not a value of the primary key DEPTNO
|
|
in DEPARTMENT, the statement fails.</p>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="rbafyrfupdating.htm" title="If you are updating a parent table, you cannot modify a primary key for which dependent rows exist.">Update tables with referential constraints</a></div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html> |