-
Finding field name of the primary key
How can I find the field name of the primary key?
-
for oracle, you could run some sql like this:
select dc.table_name,dc.constraint_name,
dcc.column_name, dcc.position
from dba_constraints dc, dba_cons_columns dcc
where dc.constraint_type = 'P'
and dc.constraint_name = dcc.constraint_name
and dc.table_name = '<table_name>'
order by dcc.position
-
For MS sql, you can try this:
select CONSTRAINT_NAME, table_name, column_name from information_schema.key_column_usage where CONSTRAINT_NAME like 'pk%'
-
Sorry, I guess I should have specified. I'm using MySQL.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|