DB2 View

DB2 TABLE DB2 Types of VIEWS

Advertisements


VIEW is nothing but the table which can be derived from one or more tables.

In other words, the view can be defined as “ The Table which can be derived from one or more tables based on selection criteria”.

A VIEW is an alternative representation of data which is derived from one or more tables.

MAX up to 15 tables can be used to create the view.

VIEW can combine the data from different tables.

VIEW can omit the columns from base tables and can only create on with some columns of the base tables.

VIEW can contain all the columns or some columns from the table.

CREATE VIEW is used to create the VIEW.

VIEW is temporary table in storage point of view and no memory will be allocated.

A VIEW can be created on single table or more than one table.

If a VIEW created with all the tables of a single table, then the data can be inserted by referring the view name in INSERT.

Advantages:

Makes data easier to use by representing the data from more than one table’s as a single table.

Restrict the access to the base tables and providing the access to the view can increase security to base table data.

Increasing controlled access over the database.

Can able to hide the complex queries and makes the end user life easy by representing the data in single table from more than one table.

Views can have the derived columns, apart from the retrieved columns.


Syntax:


CREATE VIEW View name[Columns names] AS
	(SELECT *[columns names] FROM database name. tablespace name.tablename) 
	 ON database name. tablespace name

SYSCAT.VIEWS contains the VIEWs complete information.

A VIEW is unchanged, if the base table altered when the VIEW is created on full table.

SYSCAT.VIEWS:

Note:  The above table information is collected from Internet.


Practical Example:


If any questions on the above, post your queries on DB2 Discussion forum


DB2 TABLE DB2 Types of VIEWS

Advertisements