Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
kb:pg:nasledjivanje_tabela [2019/11/14 12:33] – nessa | kb:pg:nasledjivanje_tabela [2019/11/14 12:50] (current) – nessa | ||
---|---|---|---|
Line 3: | Line 3: | ||
PostgreSQL ima mehanizam za nasleđivanje između tabela ([[https:// | PostgreSQL ima mehanizam za nasleđivanje između tabela ([[https:// | ||
- | <programlisting> | + | Primer roditeljske tabele cities i deteta capitals:<code> |
CREATE TABLE cities ( | CREATE TABLE cities ( | ||
name text, | name text, | ||
Line 13: | Line 13: | ||
state | state | ||
) INHERITS (cities); | ) INHERITS (cities); | ||
- | </programlisting> | + | </code> |
+ | |||
+ | * SELECT iz roditeljske table uvek vraća i slogove iz dece osim ako se ispred imena roditelja ne navede ključna reč ONLY npr. SELECT * FROM ONLY cities | ||
+ | * ALTER roditeljske tabele (dodavanje/ | ||
+ | * INSERT u roditeljsku tabelu se ne prenosi u decu, a ni obratno | ||
+ | * UPDATE zajedničke kolone u roditeljskoj tabeli se prenosi na decu, obratno ne | ||
+ | |||
+ | Dokumentacija PostgreSQLa kaže da postoji 1 ograničenje tj. mana u konceptu nasleđivanja tabela, a to je: | ||
+ | |||
+ | < | ||
+ | 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. | ||
+ | </code> | ||