I'm using Sybase ASE 15.5 and a stranger to this database. Straight to the point--> I'm looking for a sql query that would help me get the primary keys for all tables in sybase along with the column names on which the primary key is declared. For example, if I have the following tables, organization having primary key PK_org_id on the column org_id org_alias having primary key PK_alias_id on the column alias_id org_temp having primary key PK_org_temp_id on the columns (org_id,org_name)
then the query should return me with:
- Table_Name PK_Name Column_name
- Organization PK_org_id org_id
- Org_alias PK_alias_id alias_id
- Org_temp PK_org_temp_id org_id,org_name
I've tried the below query:
select o.name , i.name
from sysobjects o, sysindexes i
where o.id=i.id
and i.indid = 1
and o.type = 'U'
but it only returns me the table name with its primary key. I want to have the column name too.
Please help!