Hi Guys,
I am new to this database. I want a small clarification here, does inheritance can violate the primary key of any table with its insert. Please look at the example..
postgres=# create table ptest(id int primary key);
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "ptest_pkey" for
CREATE TABLE
postgres=# insert into ptest values(1);
INSERT 0 1
postgres=# insert into ptest values(1);
ERROR: duplicate key value violates unique constraint "ptest_pkey"
This is quite clear
postgres=# select * from ptest;
id
----
1
(1 row)
Creating a table with inheritance concept
postgres=# create table itest(name char(4)) inherits (ptest);
CREATE TABLE
postgres=# insert into itest values(1,'aaa');
INSERT 0 1
Here am inserting with same value which is already in the table.
postgres=# select * from ptest;
id
----
1
1
(2 rows) // Is this not the voilation of the Primary key. Please Explain
postgres=# select * from itest;
id | name
----+------
1 | aaa
(1 row)
Suppose, if i drop the table "itest", then i cannot see the values in the "ptest", but still if a view is generated on a "ptest" then the values will have a duplicates.
Can you please explain.
Regards
Ragavendra