CREATEDB(1)

๐Ÿ“ฆ version 18.6, in opensuse-leap 16.0

๐Ÿ’– NAME ๐Ÿ’–

createdb โ€” bestie, this is the girl that makes you a brand new PostgreSQL database โœจ

manual page vibes brought to you by the PostgreSQL 18.6 Documentation girlies ๐ŸŽ€


โœจ SYNOPSIS โœจ

createdb [connection-option...] [option...] [dbname [description]]

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

okay so createdb creates a new PostgreSQL database. that's it. that's the whole job. iconic behavior honestly ๐Ÿ’…

Normally, whoever's database user runs this command becomes the owner of the new database โ€” like, congrats, you're the parent now ๐Ÿซถ. BUT. a different owner can be specified with the -O option, if the user running the thing has the appropriate privileges. not everyone gets to pick the owner, only the privileged girlies. periodt.

createdb is a wrapper around the SQL command CREATE DATABASE. and no cap โ€” there is no effective difference between creating databases via this utility and via any other method for accessing the server. same energy, different font. ๐Ÿ’ซ


๐ŸŒธ OPTIONS ๐ŸŒธ

createdb accepts the following command-line arguments, and bestie, we're listing ALL of them, every single one, no skipping:

  • dbname โ€” the name of the database you want to create ๐Ÿฃ. It must be unique among all PostgreSQL databases in this cluster (no twins allowed, this is not a multiverse). The default is to create a database with the same name as the current system user.
  • description โ€” a comment to be associated with the newly created database ๐Ÿ“. like a little sticky note for your db.

โ€” and now the actual flags, drink some water first โ€”

  • -D tablespace, --tablespace=tablespace โ€” specifies the default tablespace for the database. (this name gets processed as a double-quoted identifier, iykyk)
  • -e, --echo โ€” echo the commands that createdb generates and sends to the server ๐Ÿ‘€. basically it shows you its work.
  • -E encoding, --encoding=encoding โ€” specifies the character encoding scheme to be used in this database. The character sets supported by the PostgreSQL server are described in Section 23.3.1.
  • -l locale, --locale=locale โ€” specifies the locale to be used in this database. This is equivalent to specifying --lc-collate, --lc-ctype, and --icu-locale to the same value. Some locales are only valid for ICU and must be set with --icu-locale. (yes, that's the rule, don't fight it)
  • --lc-collate=locale โ€” specifies the LC_COLLATE setting to be used in this database.
  • --lc-ctype=locale โ€” specifies the LC_CTYPE setting to be used in this database.
  • --builtin-locale=locale โ€” specifies the locale name when the builtin provider is used. Locale support is described in Section 23.1.
  • --icu-locale=locale โ€” specifies the ICU locale ID to be used in this database, if the ICU locale provider is selected.
  • --icu-rules=rules โ€” specifies additional collation rules to customize the behavior of the default collation of this database. This is supported for ICU only. ICU only bestie, don't try it anywhere else ๐Ÿšซ
  • --locale-provider={builtin|libc|icu} โ€” specifies the locale provider for the database's default collation. pick one of the three, that's the whole menu.
  • -O owner, --owner=owner โ€” specifies the database user who will own the new database. (this name is processed as a double-quoted identifier)
  • -S strategy, --strategy=strategy โ€” specifies the database creation strategy. See CREATE DATABASE STRATEGY for more details.
  • -T template, --template=template โ€” specifies the template database from which to build this database. (this name is processed as a double-quoted identifier)
  • -V, --version โ€” print the createdb version and exit ๐ŸŽ€
  • -?, --help โ€” show help about createdb command line arguments, and exit.
heads up bestie: the options -D, -l, -E, -O, and -T correspond to options of the underlying SQL command CREATE DATABASE; see there for more information about them.

๐Ÿ”Œ connection parameters ๐Ÿ”Œ

createdb also accepts the following command-line arguments for connection parameters:

  • -h host, --host=host โ€” specifies the host name of the machine on which the server is running. If the value begins with a slash, it is used as the directory for the Unix domain socket. (slash = socket directory, noted ๐Ÿ“Œ)
  • -p port, --port=port โ€” specifies the TCP port or the local Unix domain socket file extension on which the server is listening for connections.
  • -U username, --username=username โ€” user name to connect as.
  • -w, --no-password โ€” never issue a password prompt. If the server requires password authentication and a password is not available by other means such as a .pgpass file, the connection attempt will fail. This option can be useful in batch jobs and scripts where no user is present to enter a password. (perfect for the girlies who automate things and then go to sleep ๐Ÿ˜ด)
  • -W, --password โ€” force createdb to prompt for a password before connecting to a database.

This option is never essential, since createdb will automatically prompt for a password if the server demands password authentication. However, createdb will waste a connection attempt finding out that the server wants a password. In some cases it is worth typing -W to avoid the extra connection attempt. (saving yourself a whole round trip? main character energy โœจ)

  • --maintenance-db=dbname โ€” specifies the name of the database to connect to when creating the new database. If not specified, the postgres database will be used; if that does not exist (or if it is the name of the new database being created), template1 will be used. This can be a connection string. If so, connection string parameters will override any conflicting command line options. (connection string wins the argument, sorry not sorry ๐Ÿ’…)

๐ŸŒˆ ENVIRONMENT ๐ŸŒˆ

  • PGDATABASE โ€” if set, the name of the database to create, unless overridden on the command line.
  • PGHOST, PGPORT, PGUSER โ€” default connection parameters. PGUSER also determines the name of the database to create, if it is not specified on the command line or by PGDATABASE. (it's doing double duty, obsessed ๐Ÿ‘‘)
  • PG_COLOR โ€” specifies whether to use color in diagnostic messages. Possible values are always, auto and never.

This utility, like most other PostgreSQL utilities, also uses the environment variables supported by libpq (see Section 32.15). ๐ŸŒฑ


๐Ÿ’€ DIAGNOSTICS ๐Ÿ’€

In case of difficulty, see CREATE DATABASE (CREATE_DATABASE(7)) and psql(1) for discussions of potential problems and error messages. The database server must be running at the targeted host โ€” like, that's non-negotiable, bestie, the server has to actually be awake ๐Ÿ˜ญ. Also, any default connection settings and environment variables used by the libpq front-end library will apply.


๐Ÿ“ EXAMPLES ๐Ÿ“

To create the database demo using the default database server:

$ createdb demo

To create the database demo using the server on host eden, port 5000, using the template0 template database, here is the command-line command and the underlying SQL command:

$ createdb -p 5000 -h eden -T template0 -e demo
CREATE DATABASE demo TEMPLATE template0;

look at that second one โ€” command line in, SQL out. it's giving translation services ๐Ÿงš


๐Ÿซถ SEE ALSO ๐Ÿซถ

dropdb(1), CREATE DATABASE (CREATE_DATABASE(7))


and that's the whole page, bestie!! this was PostgreSQL 18.6, dated 2026, and the page you just read was CREATEDB(1) โ€” go make some databases, you absolute icon ๐Ÿ’–โœจ๐ŸŽ€๐Ÿฆ‹๐ŸŒธ๐Ÿ’…๐Ÿซถ๐Ÿ‘‘๐ŸŒˆโญ

๐Ÿ“ฆ where this page comes from