How to find all database references
Question
In trying to figure out this problem (which is still unsolved and I still have no clue what is going on), I am wondering if maybe an external reference to the table in question is causing the problem. For example, a trigger or view or some other such thing.
Is there an easy way to find all references to a given database table? Including all views, triggers, constraints, or anything at all, preferably from the command line, and also preferably without a 3rd party tool (we are using db2).
Solution
Wow, I wouldn't have thought it, but there seems to be.. Good ole DB2.
I find the publib db2 docs view very very handy by the way:
http://publib.boulder.ibm.com/infocenter/db2luw/v8//index.jsp
I just found the "SYSCAT.TABDEP" catalog view in it, which seems to contain more or less what you asked for. I suspect for anything not covered there you'll have to trawl through the rest of the syscat tables which are vast. (Unfortunately I can't seem to link you to the exact page on SYSCAT.TABDEP itself, the search facility should lead you to it fairly easily though).
Most databases these days have a set of tables which contain data about the layout of your actual schema tables, quite handy for this sort of thing.
OTHER TIPS
You can write a query search the information schema views (definition column) to find the table in all views, triggers, procedure, etc. Not sure about FK & indexes though.