Thursday, January 21, 2010

Get tables without primary key


SELECT OWNER, TABLE_NAME
FROM dba_tables t1
WHERE NOT EXISTS(
SELECT 'TRUE'
FROM dba_constraints t2
WHERE t1.TABLE_NAME = t2.TABLE_NAME
AND t2.CONSTRAINT_TYPE='P')
AND OWNER NOT IN ('SYS','SYSTEM')
ORDER BY OWNER, TABLE_NAME

No comments:

Post a Comment