75 lines
4.3 KiB
HTML
75 lines
4.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="Create and use a view" />
|
|
<meta name="DC.Relation" scheme="URI" content="rzatcgetstartsql.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="rzatccrtviewsql.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="rzatcviewmultsql.htm" />
|
|
<meta name="DC.Format" content="XHTML" />
|
|
<meta name="DC.Identifier" content="viewsql" />
|
|
<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>Create and use a view</title>
|
|
</head>
|
|
<body id="viewsql"><a name="viewsql"><!-- --></a>
|
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
|
<h1 class="topictitle1">Create and use a view</h1>
|
|
<div><div class="section">You might find that no single table contains all the information
|
|
you need. You might also want to give users access to only part of the data
|
|
in a table. Views provide a way to subset the table so that you deal with
|
|
only the data you need. A view reduces complexity and, at the same time, restricts
|
|
access.<p>You can create a view using the SQL CREATE VIEW statement. Using
|
|
the CREATE VIEW statement, defining a view on a table is like creating a new
|
|
table containing just the columns and rows you want. When your application
|
|
uses a view, it cannot access rows or columns of the table that are not included
|
|
in the view. However, rows that do not match the selection criteria can still
|
|
be inserted through a view if the SQL WITH CHECK OPTION is not used. See <a href="../sqlp/rbafywcohdg.htm">WITH CHECK OPTION on a View</a> in
|
|
the SQL Programming topic for more information about using WITH CHECK OPTION.</p>
|
|
<p>In
|
|
order to create a view you must have the proper authority to the tables or
|
|
physical files on which the view is based. See the <a href="../db2/rbafzmsthcview.htm">CREATE
|
|
VIEW statement</a> in the SQL Reference topic for a list of authorities
|
|
needed.</p>
|
|
<p>If you did not specify column names in the view definition,
|
|
the column names are the same as those for the table on which
|
|
the view is based.</p>
|
|
<p>You can make changes to a table through a view even
|
|
if the view has a different number of columns or rows than the table. For
|
|
INSERT, columns in the table that are not in the view must have a default
|
|
value.</p>
|
|
<p>You can use the view as though it were a table, even though the
|
|
view is totally dependent on one or more tables for data. The view has no
|
|
data of its own and therefore requires no storage for the data. Because a
|
|
view is derived from a table that exists in storage, when you update the view
|
|
data, you are really updating data in the table. Therefore, views are automatically
|
|
kept up-to-date as the tables they depend on are updated.</p>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<ul class="ullinks">
|
|
<li class="ulchildlink"><strong><a href="rzatccrtviewsql.htm">Create a view on a single table</a></strong><br />
|
|
</li>
|
|
<li class="ulchildlink"><strong><a href="rzatcviewmultsql.htm">Create a view combining data from multiple tables</a></strong><br />
|
|
</li>
|
|
</ul>
|
|
|
|
<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> |