kb:pg:nasledjivanje_tabela

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
kb:pg:nasledjivanje_tabela [2019/11/14 12:35] nessakb:pg:nasledjivanje_tabela [2019/11/14 12:50] (current) nessa
Line 3: Line 3:
 PostgreSQL ima mehanizam za nasleđivanje između tabela ([[https://www.postgresql.org/docs/10/ddl-inherit.html|https://www.postgresql.org/docs/10/ddl-inherit.html]]) PostgreSQL ima mehanizam za nasleđivanje između tabela ([[https://www.postgresql.org/docs/10/ddl-inherit.html|https://www.postgresql.org/docs/10/ddl-inherit.html]])
  
-Primer:<code>+Primer roditeljske tabele cities i deteta capitals:<code>
 CREATE TABLE cities ( CREATE TABLE cities (
     name            text,     name            text,
Line 13: Line 13:
     state           char(2)     state           char(2)
 ) INHERITS (cities); ) INHERITS (cities);
 +</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/brisanje kolone) se prenosi i na decu, a obratno ne
 +  * 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:
 +
 +<code>
 +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> </code>
  
  
  • kb/pg/nasledjivanje_tabela.txt
  • Last modified: 2019/11/14 12:50
  • by nessa