| PostgreSQL Reference Manual - Volume 1 - SQL Language Reference by The PostgreSQL Global Development Group Paperback (6"x9"), 716 pages ISBN 0954612027 RRP £32.00 ($49.95) Sales of this book support the PostgreSQL project! Get a printed copy>>> |
3.8.1 Caveats
Table access permissions are not automatically inherited. Therefore,
a user attempting to access a parent table must either have permissions
to do the operation on all its child tables as well, or must use the
ONLY notation. When adding a new child table to
an existing inheritance hierarchy, be careful to grant all the needed
permissions on it.
A serious limitation of the inheritance feature is that indexes (including unique constraints) and foreign key constraints only apply to single tables, not to their inheritance children. This is true on both the referencing and referenced sides of a foreign key constraint. Thus, in the terms of the above example:
-
If we declared
cities.nameto beUNIQUEor aPRIMARY KEY, this would not stop thecapitalstable from having rows with names duplicating rows incities. And those duplicate rows would by default show up in queries fromcities. In fact, by defaultcapitalswould have no unique constraint at all, and so could contain multiple rows with the same name. You could add a unique constraint tocapitals, but this would not prevent duplication compared tocities. -
Similarly, if we were to specify that
cities.nameREFERENCESsome other table, this constraint would not automatically propagate tocapitals. In this case you could work around it by manually adding the sameREFERENCESconstraint tocapitals. -
Specifying that another table's column
REFERENCES cities(name)would allow the other table to contain city names, but not capital names. There is no good workaround for this case.
These deficiencies will probably be fixed in some future release, but in the meantime considerable care is needed in deciding whether inheritance is useful for your problem.
Deprecated: In releases of PostgreSQL prior to 7.1, the default behavior was not to include child tables in queries. This was found to be error prone and also in violation of the SQL standard. You can get the pre-7.1 behavior by turning off the
sql_inheritanceconfiguration option.
| ISBN 0954612027 | PostgreSQL Reference Manual - Volume 1 - SQL Language Reference | See the print edition |