I have got a requirement of creating data dictionary from all the user tables in a sybase ase database. I can't install tools like Sybase PowerDesigner, and so I have to make it possible using SQL queries.
I have composed this query by taking the help of forums, to show the table name, column name, datatype, size and not null constraint. But I am unable to find whether the column is a Primary key or not or is a part of clustered Primary key.
SELECT O.name as "Table",
C.name as "Column",
C.length as "Length",
T.name as "Datatype",
C.status as "Allow Null",
CASE C.status
WHEN 8 THEN 'NULL'
WHEN 0 THEN 'NOT NULL'
END as "NULLS"
FROM sysobjects O,
syscolumns C,
systypes T
WHERE O.id = C.id
AND O.type = "U" -- user tables only
AND C.usertype = T.usertype
ORDER BY O.name, C.colid
Can anyone here help me to do the necessary join with the required tables to get the required flag indicating its Primary Key status. I already went through the syskeys and sysindexes table documentation but am unable to find which status there would be beneficial for my purpose.