Databases, schemas, and search_path

As per the documentation, a database is a named collection of SQL objects. It's not possible to access objects in one database from another database directly. We can access other databases using a database link (or foreign data wrappers), which is an extension, as mentioned in the previous chapter.

Tip

There are two template databases: template0 and template1 in any PostgreSQL cluster. When we create a database using CREATE DATABASE db1;, a clone of the template1 database is created. If we have a few user-created tables with some master data in template1, these will be copied to the new database. If we want to create a newdb database that is a clone of a user-created database mydb, we can use CREATE DATABASE newdb ...

Get PostgreSQL for Data Architects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.