Inheritance, shared primary keys between parent and child tables.
От | James McCarthy |
---|---|
Тема | Inheritance, shared primary keys between parent and child tables. |
Дата | |
Msg-id | CAGvkbhcFO+bg-Et4-JiWL-E7WCa9BcnZM9Wvmzwkg9SkZ7BE7A@mail.gmail.com обсуждение исходный текст |
Ответы |
Re: Inheritance, shared primary keys between parent and child
tables.
|
Список | pgsql-novice |
I thought the primary key was NOT shared between parent/child tables through inheritance.
It seems obvious that the primary key of the parent table is not shared by the child table(am I miss-understanding?)
My experience from playing around with this indicates otherwise.
For example
CREATE TABLE account (
id SERIAL PRIMARY KEY
);
CREATE TABLE account_admin (
cash INTEGER
)INHERITS (account);
CREATE TABLE account_user (
credit INTEGER
)INHERITS (account);
INSERT INTO account_admin(cash) VALUES(12);
INSERT INTO account_user(credit) VALUES(12);
INSERT INTO account_user(credit) VALUES(12);
INSERT INTO account_admin(cash) VALUES(12);
My understanding of the documentation is:
SELECT id FROM account_admin;
should return 1,2
actually returns: 1,4;
And:
SELECT id FROM account_user;
should return: 1,2
actually returns: 2,3
While
SELECT id FROM account;
returns: 1,2,3,4 as expected
Does this mean that child tables of a parent share the same primary key?
В списке pgsql-novice по дате отправления: