254 lines
		
	
	
		
			11 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			254 lines
		
	
	
		
			11 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
| <!DOCTYPE html>
 | |
| <html><head>
 | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0">
 | |
| <meta http-equiv="content-type" content="text/html; charset=UTF-8">
 | |
| <link href="sqlite.css" rel="stylesheet">
 | |
| <title>CREATE VIEW</title>
 | |
| <!-- path= -->
 | |
| </head>
 | |
| <body>
 | |
| <div class=nosearch>
 | |
| <a href="index.html">
 | |
| <img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
 | |
| </a>
 | |
| <div><!-- IE hack to prevent disappearing logo --></div>
 | |
| <div class="tagline desktoponly">
 | |
| Small. Fast. Reliable.<br>Choose any three.
 | |
| </div>
 | |
| <div class="menu mainmenu">
 | |
| <ul>
 | |
| <li><a href="index.html">Home</a>
 | |
| <li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
 | |
| <li class='wideonly'><a href='about.html'>About</a>
 | |
| <li class='desktoponly'><a href="docs.html">Documentation</a>
 | |
| <li class='desktoponly'><a href="download.html">Download</a>
 | |
| <li class='wideonly'><a href='copyright.html'>License</a>
 | |
| <li class='desktoponly'><a href="support.html">Support</a>
 | |
| <li class='desktoponly'><a href="prosupport.html">Purchase</a>
 | |
| <li class='search' id='search_menubutton'>
 | |
| <a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
 | |
| </ul>
 | |
| </div>
 | |
| <div class="menu submenu" id="submenu">
 | |
| <ul>
 | |
| <li><a href='about.html'>About</a>
 | |
| <li><a href='docs.html'>Documentation</a>
 | |
| <li><a href='download.html'>Download</a>
 | |
| <li><a href='support.html'>Support</a>
 | |
| <li><a href='prosupport.html'>Purchase</a>
 | |
| </ul>
 | |
| </div>
 | |
| <div class="searchmenu" id="searchmenu">
 | |
| <form method="GET" action="search">
 | |
| <select name="s" id="searchtype">
 | |
| <option value="d">Search Documentation</option>
 | |
| <option value="c">Search Changelog</option>
 | |
| </select>
 | |
| <input type="text" name="q" id="searchbox" value="">
 | |
| <input type="submit" value="Go">
 | |
| </form>
 | |
| </div>
 | |
| </div>
 | |
| <script>
 | |
| function toggle_div(nm) {
 | |
| var w = document.getElementById(nm);
 | |
| if( w.style.display=="block" ){
 | |
| w.style.display = "none";
 | |
| }else{
 | |
| w.style.display = "block";
 | |
| }
 | |
| }
 | |
| function toggle_search() {
 | |
| var w = document.getElementById("searchmenu");
 | |
| if( w.style.display=="block" ){
 | |
| w.style.display = "none";
 | |
| } else {
 | |
| w.style.display = "block";
 | |
| setTimeout(function(){
 | |
| document.getElementById("searchbox").focus()
 | |
| }, 30);
 | |
| }
 | |
| }
 | |
| function div_off(nm){document.getElementById(nm).style.display="none";}
 | |
| window.onbeforeunload = function(e){div_off("submenu");}
 | |
| /* Disable the Search feature if we are not operating from CGI, since */
 | |
| /* Search is accomplished using CGI and will not work without it. */
 | |
| if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
 | |
| document.getElementById("search_menubutton").style.display = "none";
 | |
| }
 | |
| /* Used by the Hide/Show button beside syntax diagrams, to toggle the */
 | |
| function hideorshow(btn,obj){
 | |
| var x = document.getElementById(obj);
 | |
| var b = document.getElementById(btn);
 | |
| if( x.style.display!='none' ){
 | |
| x.style.display = 'none';
 | |
| b.innerHTML='show';
 | |
| }else{
 | |
| x.style.display = '';
 | |
| b.innerHTML='hide';
 | |
| }
 | |
| return false;
 | |
| }
 | |
| </script>
 | |
| </div>
 | |
| <div class=fancy>
 | |
| <div class=nosearch>
 | |
| <div class="fancy_title">
 | |
| CREATE VIEW
 | |
| </div>
 | |
| </div>
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| <h1 id="syntax"><span>1. </span>Syntax</h1>
 | |
| 
 | |
| <p><b><a href="syntax/create-view-stmt.html">create-view-stmt:</a></b>
 | |
| <button id='x1535' onclick='hideorshow("x1535","x1536")'>hide</button></p>
 | |
|  <div id='x1536' class='imgcontainer'>
 | |
|  <img alt="syntax diagram create-view-stmt" src="images/syntax/create-view-stmt.gif" />
 | |
| <p><b><a href="syntax/select-stmt.html">select-stmt:</a></b>
 | |
| <button id='x1537' onclick='hideorshow("x1537","x1538")'>show</button></p>
 | |
|  <div id='x1538' style='display:none;' class='imgcontainer'>
 | |
|  <img alt="syntax diagram select-stmt" src="images/syntax/select-stmt.gif" />
 | |
| <p><b><a href="syntax/common-table-expression.html">common-table-expression:</a></b>
 | |
| <button id='x1539' onclick='hideorshow("x1539","x1540")'>show</button></p>
 | |
|  <div id='x1540' style='display:none;' class='imgcontainer'>
 | |
|  <img alt="syntax diagram common-table-expression" src="images/syntax/common-table-expression.gif" />
 | |
| </div>
 | |
| <p><b><a href="syntax/compound-operator.html">compound-operator:</a></b>
 | |
| <button id='x1541' onclick='hideorshow("x1541","x1542")'>show</button></p>
 | |
|  <div id='x1542' style='display:none;' class='imgcontainer'>
 | |
|  <img alt="syntax diagram compound-operator" src="images/syntax/compound-operator.gif" />
 | |
| </div>
 | |
| <p><b><a href="syntax/expr.html">expr:</a></b>
 | |
| <button id='x1543' onclick='hideorshow("x1543","x1544")'>show</button></p>
 | |
|  <div id='x1544' style='display:none;' class='imgcontainer'>
 | |
|  <img alt="syntax diagram expr" src="images/syntax/expr.gif" />
 | |
| <p><b><a href="syntax/filter-clause.html">filter-clause:</a></b>
 | |
| <button id='x1545' onclick='hideorshow("x1545","x1546")'>show</button></p>
 | |
|  <div id='x1546' style='display:none;' class='imgcontainer'>
 | |
|  <img alt="syntax diagram filter-clause" src="images/syntax/filter-clause.gif" />
 | |
| </div>
 | |
| <p><b><a href="syntax/literal-value.html">literal-value:</a></b>
 | |
| <button id='x1547' onclick='hideorshow("x1547","x1548")'>show</button></p>
 | |
|  <div id='x1548' style='display:none;' class='imgcontainer'>
 | |
|  <img alt="syntax diagram literal-value" src="images/syntax/literal-value.gif" />
 | |
| </div>
 | |
| <p><b><a href="syntax/over-clause.html">over-clause:</a></b>
 | |
| <button id='x1549' onclick='hideorshow("x1549","x1550")'>show</button></p>
 | |
|  <div id='x1550' style='display:none;' class='imgcontainer'>
 | |
|  <img alt="syntax diagram over-clause" src="images/syntax/over-clause.gif" />
 | |
| <p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
 | |
| <button id='x1551' onclick='hideorshow("x1551","x1552")'>show</button></p>
 | |
|  <div id='x1552' style='display:none;' class='imgcontainer'>
 | |
|  <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
 | |
| </div>
 | |
| </div>
 | |
| <p><b><a href="syntax/raise-function.html">raise-function:</a></b>
 | |
| <button id='x1553' onclick='hideorshow("x1553","x1554")'>show</button></p>
 | |
|  <div id='x1554' style='display:none;' class='imgcontainer'>
 | |
|  <img alt="syntax diagram raise-function" src="images/syntax/raise-function.gif" />
 | |
| </div>
 | |
| <p><b><a href="syntax/type-name.html">type-name:</a></b>
 | |
| <button id='x1555' onclick='hideorshow("x1555","x1556")'>show</button></p>
 | |
|  <div id='x1556' style='display:none;' class='imgcontainer'>
 | |
|  <img alt="syntax diagram type-name" src="images/syntax/type-name.gif" />
 | |
| <p><b><a href="syntax/signed-number.html">signed-number:</a></b>
 | |
| <button id='x1557' onclick='hideorshow("x1557","x1558")'>show</button></p>
 | |
|  <div id='x1558' style='display:none;' class='imgcontainer'>
 | |
|  <img alt="syntax diagram signed-number" src="images/syntax/signed-number.gif" />
 | |
| </div>
 | |
| </div>
 | |
| </div>
 | |
| <p><b><a href="syntax/join-clause.html">join-clause:</a></b>
 | |
| <button id='x1559' onclick='hideorshow("x1559","x1560")'>show</button></p>
 | |
|  <div id='x1560' style='display:none;' class='imgcontainer'>
 | |
|  <img alt="syntax diagram join-clause" src="images/syntax/join-clause.gif" />
 | |
| <p><b><a href="syntax/join-constraint.html">join-constraint:</a></b>
 | |
| <button id='x1561' onclick='hideorshow("x1561","x1562")'>show</button></p>
 | |
|  <div id='x1562' style='display:none;' class='imgcontainer'>
 | |
|  <img alt="syntax diagram join-constraint" src="images/syntax/join-constraint.gif" />
 | |
| </div>
 | |
| <p><b><a href="syntax/join-operator.html">join-operator:</a></b>
 | |
| <button id='x1563' onclick='hideorshow("x1563","x1564")'>show</button></p>
 | |
|  <div id='x1564' style='display:none;' class='imgcontainer'>
 | |
|  <img alt="syntax diagram join-operator" src="images/syntax/join-operator.gif" />
 | |
| </div>
 | |
| </div>
 | |
| <p><b><a href="syntax/ordering-term.html">ordering-term:</a></b>
 | |
| <button id='x1565' onclick='hideorshow("x1565","x1566")'>show</button></p>
 | |
|  <div id='x1566' style='display:none;' class='imgcontainer'>
 | |
|  <img alt="syntax diagram ordering-term" src="images/syntax/ordering-term.gif" />
 | |
| </div>
 | |
| <p><b><a href="syntax/result-column.html">result-column:</a></b>
 | |
| <button id='x1567' onclick='hideorshow("x1567","x1568")'>show</button></p>
 | |
|  <div id='x1568' style='display:none;' class='imgcontainer'>
 | |
|  <img alt="syntax diagram result-column" src="images/syntax/result-column.gif" />
 | |
| </div>
 | |
| <p><b><a href="syntax/table-or-subquery.html">table-or-subquery:</a></b>
 | |
| <button id='x1569' onclick='hideorshow("x1569","x1570")'>show</button></p>
 | |
|  <div id='x1570' style='display:none;' class='imgcontainer'>
 | |
|  <img alt="syntax diagram table-or-subquery" src="images/syntax/table-or-subquery.gif" />
 | |
| </div>
 | |
| <p><b><a href="syntax/window-defn.html">window-defn:</a></b>
 | |
| <button id='x1571' onclick='hideorshow("x1571","x1572")'>show</button></p>
 | |
|  <div id='x1572' style='display:none;' class='imgcontainer'>
 | |
|  <img alt="syntax diagram window-defn" src="images/syntax/window-defn.gif" />
 | |
| <p><b><a href="syntax/frame-spec.html">frame-spec:</a></b>
 | |
| <button id='x1573' onclick='hideorshow("x1573","x1574")'>show</button></p>
 | |
|  <div id='x1574' style='display:none;' class='imgcontainer'>
 | |
|  <img alt="syntax diagram frame-spec" src="images/syntax/frame-spec.gif" />
 | |
| </div>
 | |
| </div>
 | |
| </div>
 | |
| </div>
 | |
| 
 | |
| 
 | |
| <h1 id="description"><span>2. </span>Description</h1>
 | |
| 
 | |
| <p>The CREATE VIEW command assigns a name to a pre-packaged 
 | |
| <a href="lang_select.html">SELECT</a> statement. 
 | |
| Once the view is created, it can be used in the FROM clause
 | |
| of another <a href="lang_select.html">SELECT</a> in place of a table name.
 | |
| </p>
 | |
| 
 | |
| <p>If the "TEMP" or "TEMPORARY" keyword occurs in between "CREATE"
 | |
| and "VIEW" then the view that is created is only visible to the
 | |
| <a href="c3ref/sqlite3.html">database connection</a> that created it and is automatically deleted when
 | |
| the database connection is closed.</p>
 | |
| 
 | |
| <p> If a <span class='yyterm'>schema-name</span> is specified, then the view 
 | |
| is created in the specified database.
 | |
| It is an error to specify both a <span class='yyterm'>schema-name</span>
 | |
| and the TEMP keyword on a VIEW, unless the <span class='yyterm'>schema-name</span> 
 | |
| is "temp".
 | |
| If no schema name is specified, and the TEMP keyword is not present,
 | |
| the VIEW is created in the main database.</p>
 | |
| 
 | |
| <p>You cannot <a href="lang_delete.html">DELETE</a>, <a href="lang_insert.html">INSERT</a>, or <a href="lang_update.html">UPDATE</a> a view.  Views are read-only 
 | |
| in SQLite.  However, in many cases you can use an
 | |
| <a href="lang_createtrigger.html#instead_of_trigger">INSTEAD OF trigger</a> on the view to accomplish 
 | |
| the same thing.  Views are removed 
 | |
| with the <a href="lang_dropview.html">DROP VIEW</a> command.</p>
 | |
| 
 | |
| <p>If a <span class='yyterm'>column-name</span> list follows 
 | |
| the <span class='yyterm'>view-name</span>, then that list determines
 | |
| the names of the columns for the view.  If the <span class='yyterm'>column-name</span>
 | |
| list is omitted, then the names of the columns in the view are derived
 | |
| from the names of the result-set columns in the <a href="syntax/select-stmt.html">select-stmt</a>.
 | |
| The use of <span class='yyterm'>column-name</span> list is recommended.  Or, if
 | |
| <span class='yyterm'>column-name</span> list is omitted, then the result
 | |
| columns in the <a href="lang_select.html">SELECT</a> statement that defines the view should have
 | |
| well-defined names using the 
 | |
| "<a href="syntax/result-column.html">AS column-alias</a>" syntax.
 | |
| SQLite allows you to create views that depend on automatically 
 | |
| generated column names, but you should avoid using them since the 
 | |
| rules used to generate column names are not a defined part of the
 | |
| interface and might change in future releases of SQLite.
 | |
| 
 | |
| </p><p>The <span class='yyterm'>column-name</span> list syntax was added in
 | |
| SQLite versions 3.9.0 (2015-10-14).
 | |
| 
 | |
| </p>
 |