Friday, May 27, 2011
Finding the primary keys for a table
SELECT cols.table_name, cols.column_name, cols.position, cons.status, cons.owner
FROM all_constraints cons, all_cons_columns cols
WHERE cons.constraint_type = 'P'
AND cons.constraint_name = cols.constraint_name
AND cons.owner = cols.owner
and upper(cons.constraint_name) = 'SYS_C009448' --name of the constarint that got violated
ORDER BY cols.table_name, cols.position;
FROM all_constraints cons, all_cons_columns cols
WHERE cons.constraint_type = 'P'
AND cons.constraint_name = cols.constraint_name
AND cons.owner = cols.owner
and upper(cons.constraint_name) = 'SYS_C009448' --name of the constarint that got violated
ORDER BY cols.table_name, cols.position;
Sunday, May 15, 2011
Query - Combination of columns
select * FROM
tmpTable sc
WHERE sc.file_id = 681
and (sc.colA,sc.colB) in (('ABC',55), ('FED',54));
Subscribe to:
Comments (Atom)