Sunday, July 13, 2014

Difference between template0 and template1 for postgresql

In Ruby On Rails, Mostly I have to work with postgresql and that time I found about template and its quite interesting about know it. 

Here I found some difference between template0 and template1

At the point you initialize a database cluster, template0 and template1 are the same. Any location-specific stuff you want to make available to every database you create by using CREATE DATABASE should go into template1. So, for example, if you add the procedural langauge PL/python to template1, every database you create later will include PL/python.

The database template0 is intended to be a "virgin" template. It should contain only standard database objects--the ones created by initializing the cluster. As a "virgin" template, it should never be changed. Never.

If you need to specify encoding and locale settings (collation), then you can do that by copying template0. You can't do that by copying template1.

2 comments: