Unanswered: How to find the primary key in a sybase table??
For example,I have a product table which have a clustered index on columns eanno and TPNB.Clustered index are primary keys by default.
So can i assume that both the columns are primary keys?Is there any other way find using System tables.(Sybase version 11.5)
I'm using this query in ASE 15.5 and 12.5.4. I assume it will work on your version as well.
Position yourself on the db you want and run the query. This gives you all the tables, if you only want one, add the clause (o.name like 'tablename') and remove the order by.
select o.name, i.name
from sysobjects o, sysindexes i
and i.indid = 2
and o.type = 'U'
order by o.name
This should give you what you desire, the identity columns will also appear.
As mentioned earlier ,I got the productno,and barcode as a primary key (which are part of clustered index keys in my table).
I assume Primary keys are clustered index by default.So my doubt is,Is there a table can have 2 primary keys??