Creating a view-data control, Database Management System

Creating a view:

  • A query can be embedded within the CREATE VIEW STATEMENT
  • A query can have complex select statements containing join, groups and sub- queries
  • A query that describes the view cannot contain an order by clause.
  • DML operation (delete/ add / modify) cannot be applied if the view have any of the following:

 

Delete (You can't delete if view contains following)

Modify (you cannot modify if view contains following)

Insert (you cannot insert if view contains following)

  • Group functions
  • A group by clause
  • A distinct keyword
  • Group functions
  • A group by clause
  • A distinct keyword
  • Columns defined by

Expressions

  • Group functions
  • A group by clause
  • A distinct keyword
  • Columns defined by

Expressions

  • There are Not Null Columns in the base tables that are not selected by view.

Example:  Create a view named employee salary having minimum, maximum and average salary for every department.

CREATE VIEW EMPSAL (NAME, MINSAL, MAXSAL, AVGSAL) AS

SELECT D.DNAME, MIN(E.SAL),MAX(E.SAL),AVG(E.SAL)

 FROM EMP E, DEPT D

WHERE E.DEPTNO=D.DEPTNO GROUP BY D.DNAME;

To view the result of the command above you can give the following command:

SELECT * FROM EMPSAL;

You may get some sample output like:

NAME   MINSAL          MAXSA                 AVG                    SAL

--------------         ---------                ---------         -------------

ACCOUNTING            1300                      5000           2916.6667

RESEARCH                 800                      3000               2175

SALES                      950                      2850           1566.6667

To view the structure of the view so created, the command is given below:

DESCRIBE EMPSAL;

Name                                                 Null?                   Type

---------------                                   ------------   ---------------------

NAME                                                VARCHAR2           (14)

MINSAL                                               NUMBER

MAXSAL                                              NUMBER

AVGSAL                                              NUMBER

 

Posted Date: 3/11/2013 1:24:45 AM | Location : United States







Related Discussions:- Creating a view-data control, Assignment Help, Ask Question on Creating a view-data control, Get Answer, Expert's Help, Creating a view-data control Discussions

Write discussion on Creating a view-data control
Your posts are moderated
Related Questions
The ER diagram clearly showing the additional tables you have implemented. SQL table creation scripts for the tables you have set up. SQL scripts showing the sample data you

tell me the functionality,advantages and disadvantages of student database

(a) Data warehouse can be defined as "a subject-oriented, integrated, time-variant, non-volatile collection of data" in support of management's decision making process. Explain ea

In E-R Diagram how relationship type is represented ? In E-R Diagram relationship type is represented as a Diamond.

Which product produces the relation that has attributes of R1 and R2 ? Cartesian product produce the relation which has attributes of R1 and R2

What is the difference among a primary index and a secondary index? Primary Index: A primary index is an ordered file whose records are of fixed length along with two fields.

Consider the subsequent relations RENTER(rno, fname, lname, address, tel_no, pref_type, max_rent) VIEWING(rno, pno, date, comment) PROPERTY_FOR_RENT( pno, street, area ,city,

How is the database organised in Oracle? Database organized within Oracle in terms of table and table holds attributes and values. A database consists of one or more logical

What does Aggregation mean?

How are tables stored on Disk? We realise that every record of a table can have different amounts of data. This is due to in some records; some attribute values may be "zero".