Skip to content

Instantly share code, notes, and snippets.

@felclef
Created November 8, 2011 18:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save felclef/1348624 to your computer and use it in GitHub Desktop.
Save felclef/1348624 to your computer and use it in GitHub Desktop.
how to become a god in a hell look-a-like db
select
tb.table_name, count(*) as num_cons
from
user_tables tb
inner join user_constraints ct
on ct.table_name = tb.table_name
inner join user_cons_columns cc
on cc.constraint_name = ct.constraint_name
and cc.table_name = ct.table_name
where
regexp_like(tb.table_name, 'fu*k', 'i')
and ct.constraint_type = 'P'
group by
tb.table_name
order by
num_cons
/
-- why?
/*
1st cuz i can
2nd the database is a mess and uses the stupid multi-field-constraints-keys-that-some-programmers-that-suck-loves
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment