postgresql_16:7.1.59.4 Examples
PostgreSQL 16 > Reference > SQL Commands > CREATE DATABASE > Examples
To create a new database: CREATE DATABASE lusiadas;
To create a database sales owned by user salesapp with a default tablespace of salesspace: CREATE DATABASE sales OWNER salesapp TABLESPACE salesspace;
To create a database music with a different locale: CREATE DATABASE music LOCALE 'sv_SE.utf8' TEMPLATE template0; In this example, the TEMPLATE template0 clause is required if the specified locale is different from the one in template1. (If it is not, then specifying the locale explicitly is redundant.)
To create a database music2 with a different locale and a different character set encoding: CREATE DATABASE music2 LOCALE 'sv_SE.iso885915' ENCODING LATIN9 TEMPLATE template0; The specified locale and encoding settings must match, or an error will be reported.
Note that locale names are specific to the operating system, so that the above commands might not work in the same way everywhere.