REFERENCES ignored when there is inheritance?
От | Stephane Bortzmeyer |
---|---|
Тема | REFERENCES ignored when there is inheritance? |
Дата | |
Msg-id | 20050513095708.GA4628@generic-nic.net обсуждение исходный текст |
Ответы |
Re: REFERENCES ignored when there is inheritance?
|
Список | pgsql-general |
I have a table to store localization information: CREATE TABLE Localization ( ... zipcode TEXT NOT NULL, ... country INTEGER REFERENCES Countries (id) NOT NULL The table Countries is like: CREATE TABLE Countries ( id SERIAL UNIQUE, name TEXT UNIQUE NOT NULL, code CHAR(2) UNIQUE NOT NULL); And a table Contacts_short which inherits from it so all the Contacts have localization information: CREATE TABLE Contacts_short ( ... INHERITS (Localization, Objects) WITHOUT OIDS; I have 240 countries in the database. Because of a programming error, contacts were entered with a country > 240. I thought that the "REFERENCES Countries (id)" should have prevented it. Is it because of inheritance? PostgreSQL 7.4.7 Example: registry=> SELECT max(id) FROM Countries; max ----- 240 (1 row) registry=> SELECT count(*) FROM Contacts_short WHERE country > 240; count ------- 84 (1 row) To me, the last figure should have been zero.
В списке pgsql-general по дате отправления: