Best Online Tutorials

SQL Tutorial

Free SQL Tutorial

SQL Interview Questions

SQL Practice Questions

SQL Tips & Tricks

SQL Errors

SQL Books

Angular Tutorial

Free Angular Tutorial

Angular Interview Questions

Angular Practice Questions

Angular Tips & Tricks

Angular Errors

Angular Books

Node.js Tutorial

Free Node.js Tutorial

Node.js Interview Questions

Node.js Practice Questions

Node.js Tips & Tricks

Node.js Errors

Node.js Books

React.js Tutorial

Free React.js Tutorial

React.js Interview Questions

React.js Practice Questions

React.js Tips & Tricks

React.js Errors

React.js Books

SSIS Tutorial

Free SSIS Tutorial

SSIS Interview Questions

SSIS Practice Questions

SSIS Tips & Tricks

SSIS Errors

SSIS Books

SEO Tutorial

Free SEO Tutorial

SEO Interview Questions

SEO Practice Questions

SEO Tips & Tricks

SEO Errors

SEO Books

Javascript Tutorial

Free Javascript Tutorial

Javascript Interview Questions

Javascript Practice Questions

Javascript Tips & Tricks

Javascript Errors

Javascript Books

MongoDB Tutorial

Free MongoDB Tutorial

MongoDB Interview Questions

MongoDB Practice Questions

MongoDB Tips & Tricks

MongoDB Errors

MongoDB Books

Next.js Tutorial

Free Next.js Tutorial

Next.js Interview Questions

Next.js Practice Questions

Next.js Tips & Tricks

Next.js Errors

Next.js Books

SQL Interview Questions | Part 4 

Prashant Surya  |   Nov 2, 2019  |  Views: 1357
pictures

Description:

In this part we will cover the SQL Indexes and their related interview questions mentioned below one by one.

1) What are SQL Indexes?
2) How to create Indexes in SQL?
3) What are the types of Indexes in SQL?
4) When we have to use Indexing in SQL?



1.  What are SQL Indexes?

Index used for fast searching of data. 

It provides a fast way to lookup data based on the values with in column in a tables so that it could help to speed up performance of queries.

Indexes in SQL works like Index of books. 

It always helps to find data or fetch records in fast way.

For Example: 

If you want to find a particular topic in book, you will first refer to the Index of book, 

In Index you can find easily topic by using page number because all pages with topics listed in index page.

Indexes helps to speed up SELECT queries but when we use UPDATE and INSERT statement, 

Index takes more space on disk and slow down the performance of Queries.



2.  How to create Indexes in SQL?

Creation of Index:


Syntax of Index is mentioned below:

CREATE INDEX  Index_Name  ON Table_name (Column)


 


By using below syntax, we can confirm index which created on specific table.

EXEC SP_HELPINDEX  Table_name


 


If you want to remove index from table, you can use the syntax:

DROP INDEX Index_Name on Table_Name


 



3.  What are the types of Indexes in SQL?

Types of Index:

Clustered Index :

If you created Clustered Index on a table, it will help to sort the data in ascending order or descending order. 

By default, It create on table when define a primary key.

It reorders the physical order of a table.

There can be only one clustered Index on Table.
 





NON-Clustered Index :


It cannot be sorted like clustered index. 

It maintains logical order of data.

You can create more than one NON-Clustered Index on column in a table.

You can create multiple NON_CLUSTERED Index on a single column.
 







4.  When we have to use Indexing in SQL?


When to use Index:
 
Firstly, you will check the query and WHERE Clause. If Query is executing again and again, you can create Index on specific column to speed up the performance of query.

If there are no more NULL values in column on which you want to create index.

If you want to sort the data, you can create Clustered Index on Column in a table.
















Comments:
Content Contributor
Prashant Surya

Prashant Surya

Software developer at Uniserve Data Technologies Pvt. Ltd.  |   Noida, Uttar Pradesh, India

I am a software developer, freelancer and trainer working on technologies likes. MEAN stack, MERN Stack, ASP.NET full stack, WebRTC, socket.io ,PWA, SQL, JavaScript, jQuery, HTML, CSS, SEO, responsive UI/UX designing... having 7 years of experience in development in multiple domains like, eCommerce, RTA, capital markets, education, real estate...


Read related articles

SQL Interview Questions | Part 5

Prashant Surya  |   Jan 5, 2020  |  Views: 1679

SQL Interview Questions | Part 4

Prashant Surya  |   Nov 2, 2019  |  Views: 1358

SQL Interview Questions | Part 3

Prashant Surya  |   Oct 30, 2019  |  Views: 1388

SQL interview questions | Part 2

Prashant Surya  |   Oct 24, 2019  |  Views: 1299

SQL interview questions | Part 1

Prashant Surya  |   Oct 22, 2019  |  Views: 2467

Want to sell your software ?-

If you want to sell your readymade software to the genuine clients or businessman, list your software with details and demo links.

  • Sell ERP
  • Sell Website Clones
  • Sell App Clones
  • Sell Readymade Portals
  • Sell Readymade Websites
  • Sell Mobile Apps
  • Sell Window Apps

Clients will find it using our advanced search filter and will contact you directly.

No any charge for the product lsiting.

Do you own a Company ?+

Property.sale

Buy or Sell Commercial Property+

Are you a freelancer ?+

Looking for a job ?+

Are you a Service Provider ?+

Are you a blogger ?+

Do you own an IT Institute ?+



Property.sale