Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can we check that table have index or not?

How can we check that table have index or not ? if have how to find that index for a particular column for a table?

Regards, kumar

like image 519
kumar Avatar asked Apr 29 '10 08:04

kumar


People also ask

How do you check if there is an index on a table?

Answers. In Management studio, go to the table you can see + symbol for the table click on that you can see Columns,Keys,Constraints,Triggers,Indexes,Statistics. If you have Indexes for the table after you click + symbol against Indexes you get the Index name with the column for which you declared index.

How do you tell if a SQL table has an index?

In SQL Server Management Studio you can navigate down the tree to the table you're interested in and open the indexes node. Double clicking any index in that node will then open the properties dialog which will show which columns are included in the index.

How do I find the indexes on a table in SQL Server?

sp_helpindex is a system stored procedure which lists the information of all the indexes on a table or view. This is the easiest method to find the indexes in a table. sp_helpindex returns the name of the index, description of the index and the name of the column on which the index was created.


1 Answers

In SQL Server Management Studio you can navigate down the tree to the table you're interested in and open the indexes node. Double clicking any index in that node will then open the properties dialog which will show which columns are included in the index.

If you would like to use T-SQL, this might help:

SELECT
    sys.tables.name,
    sys.indexes.name,
    sys.columns.name
FROM sys.indexes
    INNER JOIN sys.tables ON sys.tables.object_id = sys.indexes.object_id
    INNER JOIN sys.index_columns ON sys.index_columns.index_id = sys.indexes.index_id
        AND sys.index_columns.object_id = sys.tables.object_id
    INNER JOIN sys.columns ON sys.columns.column_id = sys.index_columns.column_id
        AND sys.columns.object_id = sys.tables.object_id
WHERE sys.tables.name = 'TABLE NAME HERE'
ORDER BY
    sys.tables.name,
    sys.indexes.name,
    sys.columns.name
like image 81
Daniel Renshaw Avatar answered Oct 05 '22 15:10

Daniel Renshaw