SQL > ???? > Create View

??? (Views) ? ????? ???? ????. ??? ??? ????? ????? ?? ??? ???? ??? ???? ???? ?? ??? ?????? ??? ???? ????? ????.

???? ??? ??? ??? ????.

CREATE VIEW "VIEW_NAME" AS "SQL ??";

"SQL ??" ? ??? ? ????? ????? ??? SQL ?? ????.

???? ??? ?? ??? ??? ????:

Customer ??
????????
First_Namechar(50)
Last_Namechar(50)
Addresschar(50)
Citychar(50)
Countrychar(25)
Birth_Datedate

? ??? First_Name, Last_Name, ? Country? ??? ??? ??? ???? ???? ??? ????,

CREATE VIEW V_Customer
AS SELECT First_Name, Last_Name, Country
FROM Customer;

?? ????? V_Customer ?? ???? ????:

View V_Customer
????????
First_Namechar(50)
Last_Namechar(50)
Countrychar(25)

??? ???? ??? ??? ???? ????. ?? ????? ???? ??? ??? ???? ????? ? ??? ?? ?? ??? ???? ?? ??? ??? ??? ????. ??? ?? ??? ??? ???:

Store_Information ??
Store_NameSalesTxn_Date
Los Angeles150005-Jan-1999
San Diego25007-Jan-1999
Los Angeles30008-Jan-1999
Boston70008-Jan-1999

Geography ??
Region_NameStore_Name
EastBoston
EastNew York
WestLos Angeles
WestSan Diego

??? ?? ??????? ?? ?? (Region) ??? (Sales) ? ??? ???? ??? ????:

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;

???? V_REGION_SALES ?? ???? ???. ? ???? ??? ??? ??? ???? ????. ? ????? ???? ???? ??? ?????.

SELECT * FROM V_REGION_SALES;

??:

REGION SALES
East 700
West 2050

SQL CREATE INDEX >>
?


Copyright © 2021   1keydata.com   All Rights Reserved