0% found this document useful (0 votes)
26 views

db2 Views

This document discusses views in DB2, including how to create, modify, and drop views. It defines what a view is, provides the syntax to create a view using a SELECT statement on a table, how to alter an existing view by adding a column scope, and the syntax to drop a view.

Uploaded by

himanshu
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

db2 Views

This document discusses views in DB2, including how to create, modify, and drop views. It defines what a view is, provides the syntax to create a view using a SELECT statement on a table, how to alter an existing view by adding a column scope, and the syntax to drop a view.

Uploaded by

himanshu
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

DB2 - VIEWS

http://www.tutorialspoint.com/db2/db2_views.htm Copyright © tutorialspoint.com

This chapter describes introduction of views, creating, modifying and dropping the views.

Introduction
A view is an alternative way of representing the data stored in the tables. It is not an actual table
and it does not have any permanent storage. View provides a way of looking at the data in one or
more tables. It is a named specification of a result table.

Creating a view
You can create a view using the following syntax:

Syntax:

db2 create view <view_name> (<col_name>,


<col_name1...) as select <cols>..
from <table_name>

Example: Creating view for shopper.sales1 table

db2 create view view_sales1(id, itemname, qty, price)


as select id, itemname, qty, price from
shopper.sales1

Modifying a view
You can modify a view using the following syntax:

Syntax:

db2 alter view <view_name> alter <col_name>


add scope <table_or_view_name>

Example: [To add new table column to existing view ‘view_sales1’]

db2 alter view view_sales1 alter id add


scope shopper.sales1

Dropping the view


You can drop a view using the following syntax:

Syntax:

db2 drop view <view_name>

Example:

db2 drop view sales1_view

You might also like