TABLE INDEXES_beamingGoals
Vreate Indexes to improve query retrieval
speed
By the end of this lecture
students should be able to:
automatically generate sequence numbers by
using a sequence generator
V create, maintain, and use ViewWhy use indexe: F2S
» An index in database is similar to an index in a book
> Indexes in database help speed up search queries. Allow find data in a table without
scanning the entire table.
7
$2 want bananas...
PPA wo)
&* oCREATE TABLE doo PhoneBook
LasiName
FirsName
PhoneNumber
varchariS0) NOT NULL,
varchariS0) NOT NULL,
varchariS0) NOT NULL
eaeCREATE TABLE doo PhoneBook
LastName varchar(50) NOT NULL,
FirsName _varchar(50) NOT NULL,
PhoneNumber —varchar(50) NOT NULL
Result:
783-555-0110ble Indexes (1s 2S
» There are 2 types of major Indexes:
— Clustered
+ Data is stored in the order on the clustered index
+ Only 1 clustered index per table
+ Usually the Primary Key
+ Sort and store the data rows in the table based on their key value.
- Non-clustered
+ Data is not stored in the order on the non clustered index
+ Have a structure completely separate from the data rows.CREATE CLUSTERED INDEX IX PhoneBook_Cl
‘ON dbo PhoneBook (LastName, FirstName)Non - Clustered IndexCreating an Index
» Create a new index:
CREATE INDEX index_name
» Deleting an Index
(eee
2S Academy eternal Use 10v Table Indexes
— Why use indexes?
— Create, maintain and use index
2S Academy eternal Usees 25
Thank you
aS Academy ternal se