RefLib

Reference library for AI

Back

postgresql_16:7.1.59.2 Parameters

PostgreSQL 16 > Reference > SQL Commands > CREATE DATABASE > Parameters

*name*

The name of a database to create.

*user_name*

The role name of the user who will own the new database, or DEFAULT to use the default (namely, the user executing the command). To create a database owned by another role, you must be able to SET ROLE to that role.

*template*

The name of the template from which to create the new database, or DEFAULT to use the default template (template1).

*encoding*

Character set encoding to use in the new database. Specify a string constant (e.g., 'SQL_ASCII'), or an integer encoding number, or DEFAULT to use the default encoding (namely, the encoding of the template database). The character sets supported by the PostgreSQL server are described in (see postgresql_16:4.9.3.1). See below for additional restrictions.

*strategy*

Strategy to be used in creating the new database. If the WAL_LOG strategy is used, the database will be copied block by block and each block will be separately written to the write-ahead log. This is the most efficient strategy in cases where the template database is small, and therefore it is the default. The older FILE_COPY strategy is also available. This strategy writes a small record to the write-ahead log for each tablespace used by the target database. Each such record represents copying an entire directory to a new location at the filesystem level. While this does reduce the write-ahead log volume substantially, especially if the template database is large, it also forces the system to perform a checkpoint both before and after the creation of the new database. In some situations, this may have a noticeable negative impact on overall system performance.

*locale*

Sets the default collation order and character classification in the new database. Collation affects the sort order applied to strings, e.g., in queries with ORDER BY, as well as the order used in indexes on text columns. Character classification affects the categorization of characters, e.g., lower, upper, and digit. Also sets the associated aspects of the operating system environment, LC_COLLATE and LC_CTYPE. The default is the same setting as the template database. See (see postgresql_16:4.9.2.2) and (see postgresql_16:4.9.2.2) for details.

Can be overridden by setting (see create-database-lc-collate), (see create-database-lc-ctype), or (see create-database-icu-locale) individually.

Tip

The other locale settings (see guc-lc-messages), (see guc-lc-monetary), (see guc-lc-numeric), and (see guc-lc-time) are not fixed per database and are not set by this command. If you want to make them the default for a specific database, you can use ALTER DATABASE ... SET.

*lc_collate*

Sets LC_COLLATE in the database server's operating system environment. The default is the setting of (see create-database-locale) if specified, otherwise the same setting as the template database. See below for additional restrictions.

If (see create-database-locale-provider) is libc, also sets the default collation order to use in the new database, overriding the setting (see create-database-locale).

*lc_ctype*

Sets LC_CTYPE in the database server's operating system environment. The default is the setting of (see create-database-locale) if specified, otherwise the same setting as the template database. See below for additional restrictions.

If (see create-database-locale-provider) is libc, also sets the default character classification to use in the new database, overriding the setting (see create-database-locale).

*icu_locale*

Specifies the ICU locale (see (see postgresql_16:4.9.2.2)) for the database default collation order and character classification, overriding the setting (see create-database-locale). The locale provider (see create-database-locale-provider) must be ICU. The default is the setting of (see create-database-locale) if specified; otherwise the same setting as the template database.

*icu_rules*

Specifies additional collation rules to customize the behavior of the default collation of this database. This is supported for ICU only. See (see postgresql_16:4.9.2.3) for details.

*locale_provider*

Specifies the provider to use for the default collation in this database. Possible values are icu (if the server was built with ICU support) or libc. By default, the provider is the same as that of the (see create-database-template). See (see postgresql_16:4.9.1.4) for details.

*collation_version*

Specifies the collation version string to store with the database. Normally, this should be omitted, which will cause the version to be computed from the actual version of the database collation as provided by the operating system. This option is intended to be used by pg_upgrade for copying the version from an existing installation.

See also (see postgresql_16:7.1.5) for how to handle database collation version mismatches.

*tablespace_name*

The name of the tablespace that will be associated with the new database, or DEFAULT to use the template database's tablespace. This tablespace will be the default tablespace used for objects created in this database. See (see postgresql_16:7.1.85) for more information.

*allowconn*

If false then no one can connect to this database. The default is true, allowing connections (except as restricted by other mechanisms, such as GRANT/REVOKE CONNECT).

*connlimit*

How many concurrent connections can be made to this database. -1 (the default) means no limit.

*istemplate*

If true, then this database can be cloned by any user with CREATEDB privileges; if false (the default), then only superusers or the owner of the database can clone it.

*oid*

The object identifier to be used for the new database. If this parameter is not specified, PostgreSQL will choose a suitable OID automatically. This parameter is primarily intended for internal use by pg_upgrade, and only pg_upgrade can specify a value less than 16384.

Optional parameters can be written in any order, not only the order illustrated above.

Back