Database Reference
In-Depth Information
The syntax:
WHERE confrelid = 'orders'::regclass;
introduces the concept of object identifier types. They are just a short-hand trick for converting
from the name of an object through to the object identifier number for that object. The best
way to understand this is if you think of that syntax as meaning the same thing as a function
named relname2relid() .
There's more...
With Postgres, there's always a little more when you look beneath the surface. In this case,
there's a lot more, and it's important.
The aforementioned queries only covered constraints between tables. We didn't discuss
dependencies with other kinds of objects. Two important types of objects that might have
dependencies to tables are Views and Functions.
If you issue the following:
DROP TABLE orders;
the dependency on any of the views will prevent the table from being dropped. Thus, you
can then remove those views, and then drop the table.
The story with function dependencies is not as useful. Relationships between functions and
tables are not recorded in the catalog, nor is dependency information between functions
and functions. This is partly due to the fact that most function languages allow dynamic
query execution, so you wouldn't be able to tell which tables or functions that a function
would access until it executes. That's only partly the reason why most functions clearly
reference other tables and functions, so it ought to be possible to identify and store those
dependencies. However, right now, we don't do that. So make a note that you need to record
the dependency information for your functions manually, so that you'll know when and if it's
OK to remove or alter a table or other objects the functions depend upon.
 
Search WWH ::




Custom Search