0% found this document useful (0 votes)
12 views

SQL - CREATE VIEW Statement - 1keydata

Uploaded by

vickroid007
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

SQL - CREATE VIEW Statement - 1keydata

Uploaded by

vickroid007
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

3/2/2016 SQL ­ CREATE VIEW Statement | 1Keydata

SQL CREATE VIEW

SQL Data Warehousing CSS PHP HTML Database Normalization

SQL Tutorial
Basic SQL Commands
SQL SELECT
SQL DISTINCT
SQL WHERE SQL > Data Definition Language (DDL) > Create View Statement
SQL AND OR
Views can be considered as virtual tables. Generally speaking, a table has a set of definition, and it physically stores the da
SQL IN
has a set of definitions, which is build on top of table(s) or other view(s), and it does not physically store the data.
SQL BETWEEN
SQL Wildcard The syntax for creating a view is as follows:
SQL LIKE
SQL ORDER BY CREATE VIEW "VIEW_NAME" AS "SQL Statement";
SQL GROUP BY
SQL HAVING "SQL Statement" can be any of the SQL statements we have discussed in this tutorial.
SQL ALIAS
SQL AS Let's use a simple example to illustrate. Say we have the following table:
SQL SELECT UNIQUE
Table Customer
SQL JOIN
SQL INNER JOIN Column Name Data Type
SQL OUTER JOIN
First_Name char(50)
SQL LEFT OUTER JOIN
Last_Name char(50)
SQL CROSS JOIN
Address char(50)
SQL INSERT INTO
City char(50)
SQL INSERT INTO SELECT
SQL UPDATE Country char(25)
SQL DELETE FROM Birth_Date datetime

Advanced SQL and we want to create a view called V_Customer that contains only the First_Name, Last_Name, and Country columns from
SQL UNION would type in,
SQL UNION ALL
SQL Inline View CREATE VIEW V_Customer
SQL INTERSECT AS SELECT First_Name, Last_Name, Country
SQL MINUS FROM Customer;
SQL LIMIT
SQL TOP Now we have a view called V_Customer with the following structure:
SQL Subquery
View V_Customer
SQL EXISTS
SQL CASE
Column Name Data Type
SQL DECODE
First_Name char(50)
SQL AUTO INCREMENT
Last_Name char(50)
SQL IDENTITY
Country char(25)
SEQUENCE & NEXTVAL

SQL Functions We can also use a view to apply joins to two tables. In this case, users only see one view rather than two tables, and the S
SQL Average users need to issue becomes much simpler. Let's say we have the following two tables:
SQL COUNT
SQL MAX Table Store_Information
SQL MIN
Store_Name Sales Txn_Date
SQL SUM
SQL ROUND Los Angeles 1500 Jan-05-1999
San Diego 250 Jan-07-1999
String Functions
Los Angeles 300 Jan-08-1999
SQL CAST
Boston 700 Jan-08-1999
SQL CONVERT
SQL CONCATENATE
Table Geography
SQL SUBSTRING
SQL INSTR Region_Name Store_Name
SQL TRIM East Boston
http://www.1keydata.com/sql/sql­create­view.html 1/2
3/2/2016 SQL ­ CREATE VIEW Statement | 1Keydata
East Boston
SQL LENGTH
East New York
SQL REPLACE
West Los Angeles
SQL TO_DATE
West San Diego
Date Functions
and we want to build a view that has sales by region information. We would issue the following SQL statement:

CREATE VIEW V_REGION_SALES


AS SELECT A1.Region_Name REGION, SUM(A2.Sales) SALES
FROM Geography A1, Store_Information A2
WHERE A1.Store_Name = A2.Store_Name
GROUP BY A1.Region_Name;

This gives us a view, V_REGION_SALES, that has been defined to store sales by region records. If we want to find out the c
view, we type in,

SELECT * FROM V_REGION_SALES;

Result:

REGION SALES
East 700
West 2050

Next: SQL Index

3D Animation Courses
Animation Courses By Hi­Tech Acad. Join One Of Our Animation Courses

Copyright © 2016 1keydata.com All Rights Reserved Privacy Policy About Contact

http://www.1keydata.com/sql/sql­create­view.html 2/2

You might also like