Query table constraints, indexes

--Get all indexes of a table, including the name of the column to which the index belongs

sp_statistics 'Table'

 

--Get index and index attribution column and description information

sp_helpindex 'Table'

 

--Get constraint information and attribution columns of a table

sp_helpconstraint 'Table'

 

--Get the column name of the auto-increment column in a table

select    name   from    syscolumns   

  where    id=object_id('Table')   and    status   &   128   =   128

 

--Get the column name of the auto-increment column in a table

select    name   from    syscolumns   

  where    id=object_id('Table')   and     

                COLUMNPROPERTY (id, name, 'IsIdentity') = 1

 

delete constraint

alter table student drop constraint pk_Student

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326800822&siteId=291194637