Advanced Database Management System
Advanced Database Management System
Unit 1: Lecture 9
▪Example:
select rowid, actno, cname from deposit;
TYPES OF INDEXES: DUPLICATE V/S UNIQUE
▪An Index, that allows duplicate values for indexed column, is called
Duplicate Index.
▪An Index, that does not allow duplicate values for indexed column, is
called a Unique Index.
▪A Unique Index is created automatically for a table, if it contains a
primary key or unique key.
▪For a Customer table, it is not possible to create a unique index for column
city, as it contains duplicate values.
▪Unique indexes are generally created on Primary keys and unique keys.
TYPES OF INDEXES: SIMPLE V/S COMPOSITE
▪ An Index created on a single column of a table is called a
Simple Index.
▪ An Index created on more than one column is called a
Composite Index.
CREATING AN INDEX (SIMPLE INDEX)
▪Syntax:
create [unique] index index_name on table_name (column_name);
▪Example:
create index index_deposit on deposit(actno);
▪If UNIQUE option is provided while creating an index, it will be considered
as a Unique Index.
▪By default, indexes are created as Duplicate Indexes.
CREATING AN INDEX (COMPOSITE INDEX)
▪Syntax:
create [unique] index index_name on table_name
(column_name1, column_name2,….,);
▪Example:
create index index_deposit2 on deposit(cname,bname);
CREATING AN INDEX (COMPOSITE INDEX)
▪Here, second column will be considered only when the first column contains
duplicate data.
▪In such case, sorting is performed based on data of the second column.
▪Similarly, if index is created on more than two columns, other columns will
be considered only the previous all columns contain duplicate data.
MULTIPLE INDEXES ON A TABLE
▪It is possible for a table to have more than one index on different columns.
▪A table can have any number of indexes.
▪If a query, fired on a table, does not contain WHERE or ORDER BY clause,
no index is used for that query.
▪An Index is used when WHERE or ORDER BY clause is specified in query,
and they contain a column on which an Index is created.
▪If a table contains more than one index, a particular index is selected
based on the column specified in WHERE or ORDER BY clause.
MULTIPLE INDEXES ON A TABLE
▪Multiple indexes on tables must be created carefully.
▪Too many indexes may degrade the overall performance.
▪The reason behind this is, whenever a record in table is inserted, deleted
or updated, indexes created on that table also need to be updated.
▪Sorting of contents of Index is required each time such operation is
performed.
▪If there are too many indexes, this processing may take a longer time
resulting in slower system.
▪Thus, indexes speed up the data retrieval, but they slow down the other
operations such as insert, update or delete.
DESTROYING AN INDEX
▪Syntax:
drop index index_name ;
▪Example:
drop index index_deposit ;
THANK YOU…..
Appear for Quiz Assignment in Microsoft Teams.
Note: It is mandatory for all students to appear for quiz assignment, it will be
considered as present in lecture and marks will be count as progressive
assessment.
If you do not appear than it will be considered as Absent in class and marks
will be 0 (zero).