Skip to content

Instantly share code, notes, and snippets.

@zz
Created October 16, 2013 05:34
Show Gist options
  • Save zz/7003070 to your computer and use it in GitHub Desktop.
Save zz/7003070 to your computer and use it in GitHub Desktop.
Nagio oracle check no primary key tables
Select tables.owner || '.' ||
tables.table_name
as table_owner
From all_tables tables,
(Select
owner,
TABLE_NAME,
constraint_type,
CONSTRAINT_NAME
FROM ALL_CONSTRAINTS
WHERE CONSTRAINT_TYPE = 'P' /* list of all tables with PK */
) constr
Where tables.owner = constr.owner (+)
And tables.table_name = constr.table_name (+)
and tables.owner = 'CQGZF'
And constr.owner IS NULL
And constr.table_name IS NULL
ORDER BY 1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment