October 2001
Beginner to intermediate
400 pages
7h 45m
English
PostgreSQL allows tables to inherit properties and attributes from other tables. This is useful in cases in which many tables are needed to hold very similar information. In these cases, it is often possible to create a parent table that holds the common data structures, allowing the children to inherit these structures from the parent.
For instance, let’s create a table called employees:
CREATE TABLE employees (name char(10), salary numeric(9,2));
Now you can create a specific table just for cooks, who happen to need all the information that other employees need:
CREATE TABLE cooks (specialty char(10)) INHERITS(employees); SELECT * FROM cooks; name salary specialty --------------------- (0 rows) INSERT INTO cooks VALUES ('Bill', ...Read now
Unlock full access