How to create Indexes In SQL | How to choose columns when creating indexes

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone welcome back to my channel and in today's video we're going to check about i'm going to learn about index in sql so this is going to be a quick video on indexes how we create indexes why we need indexes and how to choose the columns for uh creating indexes so let's see the definition indexes are used to retrieve data from the db from the database more quickly than otherwise so for example you have a select query and the particular table has a lot of values so it can take a lot of time to give you the result give you the output so indexes are used so that your so that you get the output so that you get the output of that particular select query quicker okay so users cannot see the uh see the indexes so the indexes are created but the users cannot see it they are used to speed up searches or queries as i already said if you have a huge table which has a lot of values it will help you in speeding up the searches those select queries updating a table with indexes takes more time than updating a table without one so what this means is you should use indexes only where you you're going to select values if you're going to update values uh quite frequently it's advisable if you don't use index in that particular table so this is an this is a syntax for creating an index so create index idx underscore last thing this is what this is going to be the index name you can give it any particular name so create index index name on on whatever table so the employees is the table on whatever table name and in brackets you have to write the column name so in this case i'm going to write last name you can also have more than one column name in when you create an index so it can be last name comma another any other column it okay so so this is how we create indexes now how to choose columns when creating index now now you will ask me how to know which column name to write over your if we are creating an index on a particular table so it is advisable okay it is advisable that columns that appear in where clause or join condition those columns should be written here when you are creating an index indexes should be avoid avoided in tables that have frequent or large updates or insert operations wherever a particular table has a lot of inserts a lot of updates have updates happening you should avoid avoid creating index okay so this is why index is are need needed indexes are needed so that you can you can use select queries and you can get the output quicker uh and that's it and there are two types of indexes cluster index and non-clustered index which will be covered in another video for now just know that there are two types of index clustered and non-cluster index i have an entire video on indexing and and an in-depth video on indexing i will make sure to link that video so do check that out to understand indexing better so i hope you like like the video so don't forget to like share comment and subscribe to my channel bye
Info
Channel: Crack Concepts
Views: 23,003
Rating: 4.8782201 out of 5
Keywords: Indexes in dbms, indexes in sql, indexes in oracle
Id: VHMgs_pgbXw
Channel Id: undefined
Length: 3min 15sec (195 seconds)
Published: Sun Oct 04 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.