<?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="Department table (DEPARTMENT)" /> <meta name="abstract" content="The department table describes each department in the enterprise and identifies its manager and the department it reports to." /> <meta name="description" content="The department table describes each department in the enterprise and identifies its manager and the department it reports to." /> <meta name="DC.subject" content="examples, table, DEPARTMENT, used in examples, sample tables, UDB for, DB2, iSeries" /> <meta name="keywords" content="examples, table, DEPARTMENT, used in examples, sample tables, UDB for, DB2, iSeries" /> <meta name="DC.Relation" scheme="URI" content="rbafysamptblx.htm" /> <meta name="DC.Relation" scheme="URI" content="rbafyxmpdept.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="rbafystdept" /> <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>Department table (DEPARTMENT)</title> </head> <body id="rbafystdept"><a name="rbafystdept"><!-- --></a> <!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script> <h1 class="topictitle1">Department table (DEPARTMENT)</h1> <div><p>The department table describes each department in the enterprise and identifies its manager and the department it reports to.</p> <div class="section"><p>The department table is created with the following CREATE TABLE and ALTER TABLE statements: </p> <pre><strong>CREATE TABLE</strong> DEPARTMENT (DEPTNO <strong>CHAR</strong>(3) <strong>NOT NULL</strong>, DEPTNAME <strong>VARCHAR</strong>(36) <strong>NOT NULL</strong>, MGRNO <strong>CHAR</strong>(6) , ADMRDEPT <strong>CHAR</strong>(3) <strong>NOT NULL</strong>, LOCATION <strong>CHAR</strong>(16), <strong>PRIMARY KEY</strong> (DEPTNO)) <strong>ALTER TABLE</strong> DEPARTMENT <strong>ADD FOREIGN KEY</strong> ROD (ADMRDEPT) <strong>REFERENCES</strong> DEPARTMENT <strong>ON DELETE CASCADE</strong></pre> </div> <div class="section"><p>The following foreign key is added later.</p> </div> <div class="example"> <pre><strong>ALTER TABLE</strong> DEPARTMENT <strong>ADD FOREIGN KEY</strong> RDE (MGRNO) <strong>REFERENCES</strong> EMPLOYEE <strong>ON DELETE SET NULL</strong></pre> </div> <div class="section"><p>The following indexes are created.</p> <pre><strong>CREATE UNIQUE INDEX</strong> XDEPT1 <strong>ON</strong> DEPARTMENT (DEPTNO) <strong>CREATE INDEX</strong> XDEPT2 <strong>ON</strong> DEPARTMENT (MGRNO) <strong>CREATE INDEX</strong> XDEPT3 <strong>ON</strong> DEPARTMENT (ADMRDEPT)</pre> </div> <div class="section"><p>The following alias is created for the table. </p> <pre><strong>CREATE ALIAS</strong> DEPT <strong>FOR</strong> DEPARTMENT</pre> </div> <div class="section"><p>The following table shows the content of the columns.</p> </div> <div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" width="100%" frame="void" border="1" rules="rows"><caption>Table 1. Columns of the department table</caption><thead align="left"><tr><th align="left" valign="bottom" width="25%" id="d0e140">Column name</th> <th align="left" valign="bottom" width="75%" id="d0e142">Description</th> </tr> </thead> <tbody><tr><td align="left" valign="top" width="25%" headers="d0e140 ">DEPTNO</td> <td align="left" valign="top" width="75%" headers="d0e142 ">Department number or ID.</td> </tr> <tr><td align="left" valign="top" width="25%" headers="d0e140 ">DEPTNAME</td> <td align="left" valign="top" width="75%" headers="d0e142 ">A name describing the general activities of the department.</td> </tr> <tr><td align="left" valign="top" width="25%" headers="d0e140 ">MGRNO</td> <td align="left" valign="top" width="75%" headers="d0e142 ">Employee number (EMPNO) of the department manager.</td> </tr> <tr><td align="left" valign="top" width="25%" headers="d0e140 ">ADMRDEPT</td> <td align="left" valign="top" width="75%" headers="d0e142 ">The department (DEPTNO) to which this department reports; the department at the highest level reports to itself.</td> </tr> <tr><td valign="top" width="25%" headers="d0e140 ">LOCATION</td> <td valign="top" width="75%" headers="d0e142 ">Location of the department.</td> </tr> </tbody> </table> </div> </div> <div> <ul class="ullinks"> <li class="ulchildlink"><strong><a href="rbafyxmpdept.htm">DEPARTMENT</a></strong><br /> A complete listing of the data in table DEPARTMENT.</li> </ul> <div class="familylinks"> <div class="parentlink"><strong>Parent topic:</strong> <a href="rbafysamptblx.htm" title="This topic contains the sample tables referred to and used in this topic and the SQL Reference topic collection.">DB2 UDB for iSeries sample tables</a></div> </div> </div> </body> </html>