PostgreSQL objects hierarchy
Understanding the organization of PostgreSQL database logical objects helps in understanding object relations and interactions. PostgreSQL databases, roles, tablespaces, settings, and template languages have the same level of hierarchy, as shown in the following diagram:
Template databases
By default, when a database is created, it is cloned from a template database called template1
. The template database contains a set of tables, views, and functions, which is used to model the relation between the user defined database objects. These tables, views, and functions are a part of the system catalog schema called pg_catalog
.
Tip
The schema is very close to the namespace concept in object-oriented languages. It is often used to organize the database objects, functionality, security access, or to eliminate name collision.
The PostgreSQL server has two template databases:
template1
: The default database to be cloned. It can be...