Difference between revisions of "SQL CREATE VIEW"

From Recital Documentation Wiki
Jump to: navigation, search
 
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
=CREATE VIEW=
 
 
 
==Class==
 
SQL Applications
 
 
 
 
==Purpose==
 
==Purpose==
 
Creates a logical view based on one or more tables
 
Creates a logical view based on one or more tables
Line 11: Line 4:
  
 
==Syntax==
 
==Syntax==
CREATE [SQL] VIEW <view> [(<alias> [,...])] AS <sub-query>
+
CREATE [SQL] VIEW <view> [(<alias> [,...])] AS &#060;sub-query&#062;
 
   
 
   
  
Line 32: Line 25:
 
|-
 
|-
 
|}
 
|}
 +
  
 
When the view is created, the view definition is written into the sysodbc.ini file in the current directory.  If no sysodbc.ini file currently exists, it will be created.  The DROP VIEW command removes the view definition from this file.  The view will be available until the DROP VIEW command is issued or the sysodbc.ini file is manually modified.  The data extracted from the view is the data current at the time of the SELECT statement, not at the time of the view creation.
 
When the view is created, the view definition is written into the sysodbc.ini file in the current directory.  If no sysodbc.ini file currently exists, it will be created.  The DROP VIEW command removes the view definition from this file.  The view will be available until the DROP VIEW command is issued or the sysodbc.ini file is manually modified.  The data extracted from the view is the data current at the time of the SELECT statement, not at the time of the view creation.
Line 39: Line 33:
 
<code lang="recital">
 
<code lang="recital">
 
// Create a view based on price being over $10
 
// Create a view based on price being over $10
CREATE VIEW OverTen AS
+
CREATE VIEW OverTen AS;
SELECT * FROM orders WHERE price > 10;
+
SELECT * FROM orders WHERE price > 10
  
 
// Create a view based on price being over $20
 
// Create a view based on price being over $20
CREATE SQL VIEW OverTwenty AS
+
CREATE SQL VIEW OverTwenty AS;
SELECT * FROM orders WHERE price > 20;
+
SELECT * FROM orders WHERE price > 20
 
</code>
 
</code>
  
  
 
==Products==
 
==Products==
Recital Database Server, Recital Mirage Server, Recital Terminal Developer
+
Recital Server, Recital  
 
[[Category:Documentation]]
 
[[Category:Documentation]]
[[Category:SQL]]
+
[[Category:SQL|CREATE VIEW]]
 
[[Category:Commands]]
 
[[Category:Commands]]

Latest revision as of 12:44, 6 January 2010

Purpose

Creates a logical view based on one or more tables


Syntax

CREATE [SQL] VIEW <view> [(<alias> [,...])] AS <sub-query>


See Also

DROP VIEW, SELECT


Description

The CREATE VIEW or CREATE SQL VIEW commands create a logical view based on one or more tables. A view is a logical table that allows you to access data from other tables. A view itself contains no data.


Keywords Description
view The name of the view to be created.
alias This is an optional identifier that names a column in the view. The number of columns that you name must match the number of columns in the sub-query
AS sub-query This identifies columns and rows of the tables from which the view is created. The sub-query is a SELECT statement.


When the view is created, the view definition is written into the sysodbc.ini file in the current directory. If no sysodbc.ini file currently exists, it will be created. The DROP VIEW command removes the view definition from this file. The view will be available until the DROP VIEW command is issued or the sysodbc.ini file is manually modified. The data extracted from the view is the data current at the time of the SELECT statement, not at the time of the view creation.


Example

// Create a view based on price being over $10
CREATE VIEW OverTen AS;
SELECT * FROM orders WHERE price > 10
 
// Create a view based on price being over $20
CREATE SQL VIEW OverTwenty AS;
SELECT * FROM orders WHERE price > 20


Products

Recital Server, Recital