Company
Date Published
Author
Angelico de los Reyes
Word count
623
Language
English
Hacker News points
None

Summary

When creating a new database in Postgres, you're essentially basing it on an existing standard system database called `template1`, which contains all the default settings and configurations for a new database cluster. This means that any modifications made to `template1` will be automatically applied to subsequent databases created from it. However, this also means that if something goes wrong with `template1`, you'll have to recreate it from scratch. To avoid this, you can create a custom template database using the `ALTER DATABASE` command and base new databases from it instead. This allows for more control over the settings and configurations of your database cluster, and provides a safe way to create databases without worrying about polluting the default `template1`. Additionally, if something goes wrong with `template1`, you can fall back on the `template0` database, which contains the same data as `template1` but should never be modified. By using custom template databases, you can create a clean and organized database cluster that meets your specific needs.