Updated on 2022-11-02 GMT+08:00

TEMPLATE Option

RDS for PostgreSQL provides two default templates for you to create a database: template0 and template1. Their differences are as follows:

  • When template1 is used, the character set or collation defined in this template cannot be changed. For details, see Configuring the Collation of a Database in a Locale.
    CREATE DATABASE my_db WITH TEMPLATE template1 ;
  • When template0 is used, you can change the character set and collation. For details, see Configuring the Collation of a Database in a Locale.
    CREATE DATABASE my_db WITH ENCODING = 'UTF8' LC_COLLATE ='zh_CN.utf8' LC_CTYPE ='zh_CN.utf8' TEMPLATE = template0 ;
  • If no template is specified during database creation, template1 is used by default. You can also specify a custom template to create a database.
    CREATE DATABASE my_db WITH TEMPLATE = mytemplate;