sql server
select b.column_name
from information_schema.table_constraints a
inner join information_schema.constraint_column_usage b
on a.constraint_name = b.constraint_name
where a.constraint_type = 'PRIMARY KEY'
and a.table_name = 'Goodsdoc'
----------------------------------------------------------------------
SELECT a.name
FROM syscolumns a
inner join sysobjects d on a.id=d.id
where d.name='goodsdoc' and exists(SELECT 1 FROM sysobjects where xtype='PK' and parent_obj=a.id and name in (
SELECT name FROM sysindexes WHERE indid in(
SELECT indid FROM sysindexkeys WHERE id = a.id AND colid=a.colid
)))
----------------------------------------------------------------------
oracle
select t.*,i.index_type from user_ind_columns t,user_indexes i
where t.index_name = i.index_name and t.table_name = i.table_name
and t.table_name = 'GOODSDOC';