CREATE VIEW Dateorders (odate, ocount) AS SELECT odate, COUNT (*)
FROM Orders GROUP BY odate;
Bu faqat o‘qish uchun tasvir chunki agrеgat funksiya va GROUP BY mavjud.
CREATE VIEW Londoncust AS SELECT *
FROM Customers WHERE city = 'London';
Bu tasvir modifikatsiya qilinuvchi.
CREATE VIEW Sales (name, number, percentage) AS SELECT sname, snum, comm*100
FROM Salespeople WHERE city = 'SanJose';
Bu faqat o‘qish uchun, chunki "comm * 100" ifoda ishlatiladi.
CREATE VIEW Salesonthird AS SELECT *
FROM Salespeople
WHERE odate = 10/03/1990);
Bu ANSI bo‘yicha faqat o‘qish uchun so‘rov chunki ostki so‘rov mavjud. Lеkin ba‘zi dasturlarda modifikatsiya qilinuvchi bo‘lishi mumkin.
CREATE VIEW Someorders AS SELECT snum, onum, cnum FROM Orders
WHERE odate IN (10/03/1990,10/05/1990);
Bu modifikatsiya qilinuvchi tasvir.
Tasvirlarni o‘chirish. Tasvirlarni o‘chirish quyidagicha amalga oshiriladi:
DROP VIEW view_name;
Misol. CUSTOMERS jadvali asosida yaratilgan CUSTOMERS_VIEW tasvirni o‘chirish.
DROP VIEW CUSTOMERS_VIEW;
Tasvirni o‘zgartirish komandasi ALTER VIEW.
ALTER VIEW tasvir_nomi [(ustun_1, ustun_2, )] AS ifoda_SELECT
Masalan OrdersProductsCustomers tasvirni o‘zgartirish:
AS SELECT Orders.CreatedAt AS OrderDate, Customers.FirstName AS Customer, Products.ProductName AS Product, Products.Manufacturer AS Manufacturer FROM Orders
INNER JOIN Products ON Orders.ProductId = Products.Id INNER JOIN Customers ON Orders.CustomerId = Customers.Id;
Do'stlaringiz bilan baham: |