createdb
Creates a new database.
Synopsis
createdb [ <connection-option> ... ]
[ <option> ... ]
[ <dbname> [ <description> ] ]
createdb -? | --help
createdb -V | --version
Description
createdb creates a new database in a Greengage DB system.
Normally, the database user who runs this command becomes the owner of the new database. However, a different owner can be specified via the -O option, if the executing user has appropriate privileges.
createdb is a wrapper around the SQL command CREATE DATABASE.
Options
- <dbname>
-
The name of the database to be created. The name must be unique among all other databases in the Greengage DB system. If not specified, the value is taken from the
PGDATABASEenvironment variable, then fromPGUSER, and defaults to the current system user if neither is set. - <description>
-
A comment to be associated with the newly created database. Descriptions containing white space must be enclosed in quotes.
- -D <tablespace> | --tablespace=<tablespace>
-
Specify the default tablespace for the database. This name is processed as a double-quoted identifier.
- -e | --echo
-
Echo the commands that
createdbgenerates and sends to the server. - -E <encoding> | --encoding <encoding>
-
Character set encoding to use in the new database. Specify a string constant (such as
UTF8), an integer encoding number, orDEFAULTto use the default encoding. - -l <locale> | --locale <locale>
-
Specify the locale to be used in this database. This is equivalent to specifying both
--lc-collateand--lc-ctype. - --lc-collate <locale>
-
Specify the
LC_COLLATEsetting to be used in this database. - --lc-ctype <locale>
-
Specify the
LC_CTYPEsetting to be used in this database. - -O <owner> | --owner=<owner>
-
The name of the database user who will own the new database. Defaults to the user running this command. This name is processed as a double-quoted identifier.
- -T <template> | --template=<template>
-
The name of the template from which to create the new database. Defaults to
template1. This name is processed as a double-quoted identifier. - -V | --version
-
Print the
createdbversion and exit. - -? | --help
-
Show help about
createdbcommand line arguments, and exit.
The options -D, -l, -E, -O, and -T correspond to options of the underlying SQL command CREATE DATABASE.
Connection options
- -h <host> | --host=<host>
-
The host name of the machine on which the Greengage DB master is running. If not specified, reads from the
PGHOSTenvironment variable or defaults tolocalhost. - -p <port> | --port=<port>
-
The TCP port on which the Greengage DB master is listening for connections. If not specified, reads from the
PGPORTenvironment variable or defaults to5432. - -U <username> | --username=<username>
-
The database role name to connect as. If not specified, reads from the
PGUSERenvironment variable or defaults to the current system role name. - -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.
- -W | --password
-
Force a password prompt.
- --maintenance-db=<dbname>
-
The name of the database to connect to when creating the new database. If not specified, the
postgresdatabase will be used; if that does not exist (or if it is the name of the new database being created),template1will be used.
Examples
Create the test database using the default options:
$ createdb test
Create the demo database using the Greengage DB master on host mdw, port 54321, using the LATIN1 encoding scheme:
$ createdb -p 54321 -h mdw -E LATIN1 demo