5 Nisan 2012 Perşembe akşamı gerçekleşen sanal sınıf oturumunda View örneklerini ele alırken yazmış olduğumuz kodları aşağıda bulabilirsiniz. Ayrıca, bu dersin video kaydına da buradan ulaşabilirsiniz.
select ProductID,
ProductName,
UnitPrice,
UnitsInStock
from Products
where UnitsInStock > 0
and UnitPrice >= 10
-- View Oluşturmak
create view StoktakiUrunler
as
select ProductID,
ProductName,
UnitPrice,
UnitsInStock
from Products
where UnitsInStock > 0
select * from Products
select * from StoktakiUrunler
update Products set UnitsInStock = 0 where UnitPrice = 10
select * from Customers
create view SecilmisMusteriler
as
select * from Customers
where Region is not null and Fax is not null
select * from SecilmisMusteriler
select CompanyName,ContactName,City from SecilmisMusteriler where City like 'S%' order by ContactName
select CompanyName,ContactName,City
from SecilmisMusteriler
where City like 'S%' and CompanyName not like 'W%'
order by ContactName
-- View'ü güncellemek
alter view StoktakiUrunler
as
select ProductID as UrunNo,
ProductName Ad,
UnitPrice Fiyat,
UnitsInStock [Stok Miktari],
UnitsOnOrder 'SiparisMiktari'
from Products
where UnitsInStock > 0
select Ad, Fiyat, SiparisMiktari from StoktakiUrunler where SiparisMiktari > 0 order by SiparisMiktari desc
-- View'ü Silmek
drop view StoktakiUrunler
select * from StoktakiUrunler
create view StoktakiUrunler
as
select ProductID,
ProductName,
UnitPrice,
UnitsInStock
from Products
where UnitsInStock > 0
select SupplierID from StoktakiUrunler
select aramizdaFarkYok from StoktakiUrunler
-- View Oluştururken tablo kullanabiliyorsak , tablo gibi kullanabildigimiz diger bir view'den de faydalanabiliriz
create view StoktakiUrunAdlari
as
select ProductName from StoktakiUrunler
select * from StoktakiUrunAdlari
select * from StoktakiUrunler
update StoktakiUrunler set UnitPrice = 20 Where ProductID = 1
select * from StoktakiUrunler
select ProductID, ProductName as 'Ürün Adı' from Products where 'Ürün Adı' = 'Chai'
select Ad,Fiyat,[SiparisMiktari] from StoktakiUrunler where [SiparisMiktari] > 0 order by 3
select 'deneme'
select * from Products
select * from Categories
create view UrunListesi
as
select Products.ProductID, Products.ProductName, Categories.CategoryName
from Products join Categories on Products.CategoryID = Categories.CategoryID
select * from UrunListesi
select ProductName from UrunListesi where CategoryName = 'Beverages'
-- acikakademi@acikakademi.com
--SORU: View üzerinde her şart altında insert işlemi gerçekleştirilebilir.
-- a) Doğru
-- b) Yanlış
Hiç yorum yok:
Yorum Gönder