query to find keys in a table
Posted on 2012-04-11
i have this query which tells what are the primary keys in a table
SELECT cols.table_name, cols.column_name, cols.position, cons.status, cons.owner
FROM all_constraints cons, all_cons_columns cols
WHERE cols.table_name = 'PERSON_DATA'
AND cons.constraint_type = 'P'
AND cons.constraint_name = cols.constraint_name
AND cons.owner = cols.owner
ORDER BY cols.table_name, cols.position;
Any one care to explain what are the tables : all_constraints and all_cons_columns
and what is cons.constraint_type = 'P'