Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Chapter Nine Data Manipulation Language (DML) Views Objectives Definition Creating views Retrieve data from a view Drop a view 1 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. 2 VIEWS DATABASE OBJECTS CREATE VIEW COSCStudent AS SELECT ID, Name, GPA FROM Student WHERE Major=‘COSC’; DESCRIBE COSCStudent; 3 Practice: Create a view called Customer_v with the attributes: -Customer -Customer -Customer -Customer -Customer -Customer number last name Street City State zip code 4 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 5 VIEWS DATABASE OBJECTS Aliases Column Name: CREATE VIEW COSCStudent AS SELECT ID COSCid, name COSCName, GPA FROM Student WHERE Major=‘COSC’; 6 VIEWS DATABASE OBJECTS Retrieving Data from View: SELECT * FROM COSCStudent; SELECT FROM COSCid, COSCname COSCStudent; 7 Practice: Display all the fields in Cust_Sale_v 8 VIEWS DATABASE OBJECTS Example: CREATE VIEW COSCData (minsal, maxsal, avesal) AS SELECT MIN(salary), MAX (salary), AVG (salary) FREOM faculty WHERE dept =‘COSC’; 9 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 10 VIEWS DATABASE OBJECTS Removing a View: DROP VIEW majors; 11 Practice: Remove the view Cust_v 12 Practice: Create a view using a sub-query. 13