I have to reterive the primary key given the table name as input.
The following query takes about 3 seconds to execute and its costly for me as its executed in loop.
SELECT COLUMN_NAME FROM USER_CONS_COLUMNS UCC, USER_CONSTRAINTS UC
WHERE UC.CONSTRAINT_NAME= UCC.CONSTRAINT_NAME
AND UC.OWNER= UCC.OWNER
AND UC.TABLE_NAME = <table_name>
Is there any way to optmize the above query or get the primary key of the table in other way?