Search code examples
sybasesap-ase

Is There a Query for Indexes?


I want know what are the indexes of a table. I am using ASE ISQL and I can know the indexes by right click on the table and selecting DDL, however, there is a developer in another machine that his not familiar to sybase, and I want to know the indexes of his database (his using ASE).

Is there a query for that ?


Solution

  • There are a number of different ways to view the indexes in your database.

    sp_helpindex can be used to show the indexes associated with a particular table.

    sp_helpindex TABLE_NAME
    

    sp_help can be used to list all the properties of a table, including the associated indexes.

    sp_help TABLE_NAME
    

    To get the list of all indexes and their associated tables you can use the following query

    use DATABASE_NAME
    go
    
    select sysobjects.name as TABLE_NAME, sysindexes.name as INDEX_NAME
    from sysobjects,sysindexes where
    sysobjects.type = 'U' and
    sysobjects.id = sysindexes.id and
    sysindexes.indid between 1 and 254
    order by sysobjects.name,sysindexes.indid
    go