set pagesize 300
set linesize 205
set head on
set echo off
spool tblwopk
accept usrid prompt ‘Enter User Name : ‘
accept table_name prompt ‘Enter Table Name : ‘
column PrimaryKey format a80 heading ‘Follwoing Are Primary Keys’
select substr(a.column_name, 1, 20) || ‘ Position : ‘ || to_char(a.position) PrimaryKey
from dba_cons_columns a, dba_constraints b
where b.table_name = upper(‘&TABLE_NAME’)
and b.owner = upper(‘&usrid’)
and a.constraint_name = b.constraint_name
and b.constraint_type = ‘P’
order by a.position;