Lab Manual 11 PDF
Lab Manual 11 PDF
Lab Instructor:
Ms. Hira Kanwal
Student Name
Student Roll #
Department
Batch/Year/Section
Marks Signature
11.1. Objective
1. Views
2. Indexes
11.2. VIEW
The SQL VIEW is, a virtual table that does not physically exist. Rather, it is created by a
SQL statement that joins one or more tables.
A view always shows up-to-date data. The database engine recreates the data, using the
view's SQL statement, every time a user queries a view.
Syntax:
SELECT columns
FROM table
[WHERE condition];
11.3. INDEX
An index is a copy of selected columns of data from a table that can be searched very
efficiently.
A database index is a data structure that improves the speed of data retrieval operations on
a database table at the cost of additional writes and storage space to maintain the index data
structure.
A clustered index actually describes the order in which records are physically stored on the
disk, hence the reason you can only have one. A clustered index is essentially a sorted copy
of the data in the indexed columns.
A Non-Clustered Index defines a logical order that does not match the physical order on
disk.
Notes:
1. A table that has a clustered index is referred to as a clustered table and is stored in a
B-tree structure. A table that has no clustered index is referred to as a heap.
2. A table can have only one clustered index, while non-clustered indexes can be more
than one. SQL server 2008 support upto 999 nonclustered indexes.
Syntax:
11.4.3. Alter the view created in 11.4.1 to include those customers data, whose Area is ‘LHR’