πŸŽ“ Computer Science & Engineering Portal

Master Engineering Disciplines with Structured Notes

Comprehensive academic lecture notes, exam-oriented unit summaries, laboratory manuals, and previous year question papers designed strictly for university students.

πŸ“‘

University Syllabi

AKTU & AICTE aligned semester guidelines.

πŸ“

Exam Question Papers

Previous 5 years solved university papers.

πŸ’‘

Lab Manuals & Viva

Practical codes with outputs & interview Qs.

Core Subjects & Units Hub

Click on any specific unit to immediately view its lecture notes below

Viewing All Lectures

SQL Index

SQL Index

  • Indexes are special lookup tables. It is used to retrieve data from the database very fast.
  • An Index is used to speed up select queries and where clauses. But it shows down the data input with insert and update statements. Indexes can be created or dropped without affecting the data.
  • An index in a database is just like an index in the back of a book.
  • For example: When you reference all pages in a book that discusses a certain topic, you first have to refer to the index, which alphabetically lists all the topics and then referred to one or more specific page numbers.

1. Create Index statement

It is used to create an index on a table. It allows duplicate value.

Syntax

  1. CREATE INDEX index_name  
  2. ON table_name (column1, column2, ...);  

Example

  1. CREATE INDEX idx_name  
  2. ON Persons (LastName, FirstName);  

2. Unique Index statement

It is used to create a unique index on a table. It does not allow duplicate value.

Syntax

  1. CREATE UNIQUE INDEX index_name  
  2. ON table_name (column1, column2, ...);  

Example

  1. CREATE UNIQUE INDEX websites_idx  
  2. ON websites (site_name);  

3. Drop Index Statement

It is used to delete an index in a table.

Syntax

  1. DROP INDEX index_name;  

Example

  1. DROP INDEX websites_idx;  

Labels: ,

Discussion & Queries (<$I18NNumComments$>):

<$CommentPager$>
<$I18NAtCommentTimeWithPermalink$>, <$I18NCommentAuthorSaid$>

<$BlogCommentBody$>

<$BlogCommentDeleteIcon$>
<$CommentPager$>