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

What are stored and derived attributes, What are stored and derived attribu...

What are stored and derived attributes? Stored attributes: The attributes keeps in a data base are known as stored attributes. Derived attributes: The attributes that are de

Entity relationship model, Let us first look into some of the important fea...

Let us first look into some of the important features of ER model. Entity relationship model is a high-level conceptual data model. It permits us to define the data invo

Difference between internal tables and extra datasets, What is the differen...

What is the difference between internal tables and extract datasets? The lines of an internal table always have the similar structure. By using extract datasets, you can ha

Explain about the guard condition, What is a guard condition? Explain it wi...

What is a guard condition? Explain it with a suitable example. The guard-condition is a Boolean expression written with respect to parameters of triggering event and attributes

Primary and foreign key, Primary Key The primary key is the candidate k...

Primary Key The primary key is the candidate key that is selected by the database designer as the principal denotes of identifying entities within an entity set. The left candi

Sequential file organisation, Sequential File Organisation The most nec...

Sequential File Organisation The most necessary way to organise the collection of records in a file is to use sequential Organisation. Records of the file are stored in series

Three level architecture of dbms-logical architecture, Three Level Architec...

Three Level Architecture of DBMS or Logical DBMS Architecture The logical architecture defines how data in the database is perceived by users. It is not deals with how the da

Sql queries, find a name whose address is erode from student table

find a name whose address is erode from student table

Describe interfaces for the dba, Describe Interfaces for the DBA? Inte...

Describe Interfaces for the DBA? Interfaces for the DBA - Most database systems holds privileged commands which could be used only through the DBA's staff. These involves com

Draw enhanced er-diagram for hierarchy of a student database, Draw an EER d...

Draw an EER diagram that captures the "is-a" hierarchy of students in another simple database. The database captures both the "basic" information (say, student ID and student name)

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