My blog has moved!

You should be automatically redirected. If not, visit
http://benohead.com
and update your bookmarks.

Thursday, April 26, 2012

Sybase: Find all tables in a database with a unique index

The following statement will return a list of all user tables in the current database which have a unique index:

SELECT o.name FROM sysobjects o, sysindexes i WHERE o.id = i.id AND o.type='U' AND i.status & 2 = 2 GROUP BY o.name ORDER BY o.name
 
If you're also interested in the index name, use the following:
 
SELECT o.name, i.name FROM sysobjects o, sysindexes i WHERE o.id = i.id AND o.type='U' AND i.status & 2 = 2 ORDER BY o.name

No comments:

Post a Comment