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
Define Deadlock detection If a system does not employ a few protocols that make sure deadlock freedom, after that a detection and recovery scheme should be used. An algorithm

give some example real-life situations where DBMS are most suiitabe

what is attribute is attribute inheritance in dbms?

Question 1: a) What is the difference between a non-impact and impact printer? b) Which type of printer is generally used in a supermarket to print your receipt? Describe

Explain concurrency control? Concurrency control Oracles multiversion concurrency control varies from the concurrency mechanism used by some other data base vendors. Read

What is DML (Data Manipulation Language)? This language that enable user to access or manipulate data as organised by appropriate data model. Procedural DML or Low level: DM

What is serializability? Explain its types? The data base system must control concurrent implementation of transactions, to ensure that the data base state remains consistent.

Table_Name( attribute_1, attribute_2, attribute_3, ….. ,attribute_x) Primary Key ( attribute_1, attribute_2) Foreign Key attribute_4 References Table_Name_2 (repeat for each fore

Give detail description on Transactions. - Using transactions we can group all SQL commands into a single unit. - Transaction begins with some task and finishes only when a

What is the difference between WHERE and HAVING clauses?. Predicates in the WHERE clause applies to every tuple while the predicate in the HAVING clause applies to groups.