Creating a view-data control, Database Management System

Assignment Help:

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

 


Related Discussions:- Creating a view-data control

Query evolution, what is query processing ,query optimization and performan...

what is query processing ,query optimization and performance turring?

Explain hierarchical model, Explain Hierarchical Model ? Hierarchical ...

Explain Hierarchical Model ? Hierarchical Model - It was established to model several kinds of hierarchical organizations which exist in the real world. It uses tree structur

Describe integrity and security, Describe integrity and security? a)   ...

Describe integrity and security? a)      Domain constraint b)      Referential integrity A value that appears in one relation for a given set of attributes also appear fo

Explain query execution plan, Explain query execution plan? - Optimizer...

Explain query execution plan? - Optimizer available in SQL Server optimizes code to be effectively executed. - A query execution plan demonstrates how this optimizer would r

The proliferation of object-oriented methods, The Proliferation of Object-O...

The Proliferation of Object-Oriented Methods The first few years of the 1990s saw blossoming of around fifty various object oriented methods. This proliferation is a sign of g

Differentiate between procedural and non procedural language, Differentiate...

Differentiate between Procedural and non procedural languages ? Procedural and non procedural languages - A procedural language specifies the operations to be performed on th

What is secondary index, What is Secondary Index While making the index...

What is Secondary Index While making the index, generally the index table is kept in the primary memory (RAM) and the main table, because of its size is keeps in the secondary

Clinic, Need a sample of a clinic database relationships

Need a sample of a clinic database relationships

Trigger , Flights(FlightNo, DeptDateTime, Origin, ArrivalDateTime, Destinat...

Flights(FlightNo, DeptDateTime, Origin, ArrivalDateTime, Destination, Capacity, SoldSeats) Tickets(FlightNo, Seat, CustID) Where - flightNo is the PK of the flights table - DeptDa

Explain clustering file organization, Explain Clustering file organization ...

Explain Clustering file organization (i) Determine if a record of file is physically ordered on a nonkey field - that does not comprise a different value for each record - that

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd