Download presentation
Presentation is loading. Please wait.
Published byMyron Phelps Modified over 9 years ago
1
1 Chapter Nine Data Manipulation Language (DML) Views Objectives Definition Creating views Retrieve data from a view Drop a view
2
2 VIEWS DATABASE OBJECTS 1-TABLE 2-VIEW -What is a view? -Why using a view? Restrict database access. Make complex queries easy. Represent data from different tables Represent different Views of the same data.
3
3 CREATE VIEW COSCStudent AS SELECT ID, Name, GPA FROM Student WHERE Major=‘COSC’; DESCRIBE COSCStudent; VIEWS DATABASE OBJECTS
4
4 Practice: Create a view called Customer_v with the attributes: -Customer number -Customer last name -Customer Street -Customer City -Customer State -Customer zip code
5
5 Practice: Create a view for customer sales person called Cust_Sale_v with the attributes: -Customer number -Customer last name -Sales Rep Number -Sales Person First Name -Sales Person Last Name
6
6 Aliases Column Name: CREATE VIEWCOSCStudent AS SELECTID COSCid, name COSCName, GPA FROMStudent WHEREMajor=‘COSC’; VIEWS DATABASE OBJECTS
7
7 Retrieving Data from View: SELECT* FROMCOSCStudent; SELECTCOSCid, COSCname FROMCOSCStudent; VIEWS DATABASE OBJECTS
8
8 Practice: Display all the fields in Cust_Sale_v
9
9 Example: CREATE VIEW COSCData (minsal, maxsal, avesal) AS SELECTMIN(salary), MAX (salary), AVG (salary) FREOMfaculty WHEREdept =‘COSC’; VIEWS DATABASE OBJECTS
10
10 Practice: Create a view called Cust_v with the attributes: -Customer number -Customer name (Last, First) -Customer Address (Street, city, state, zip) -Customer balance -Customer credit limit -Sales Rep Number
11
11 Removing a View: DROP VIEW majors; VIEWS DATABASE OBJECTS
12
12 Practice: Remove the view Cust_v
13
13 Practice: Create a view using a sub-query.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.