createdb
Creates a new database.
Synopsis
createdb [<connection_options>] [<database_options>] [-e | --echo] [<dbname> ['<description>']]
createdb --help
createdb --version
where:
<connection_options> =
[-h <host> | --host <host>]
[-p <port> | -- port <port>]
[-U <username> | --username <username>]
[-W | --password]
<database_options> =
[-D <tablespace> | --tablespace <tablespace>]
[-E <encoding> | --encoding <encoding>]
[-O <username> | --owner <username>]
[-T <template>| --template <template>]
Description
createdb
creates a new database in a HAWQ system.
Normally, the database user who executes 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
The name of the database to be created. The name must be unique among all other databases in the HAWQ system. If not specified, reads from the environment variable PGDATABASE
, then PGUSER
or defaults to the current system user.
Optional comment to be associated with the newly created database. Descriptions containing white space must be enclosed in quotes.
-e, –echo
Echo the commands that createdb generates and sends to the server.
-D, —tablespace
The default tablespace for the database.
-E, —encoding
Character set encoding to use in the new database. Specify a string constant (such as 'UTF8'
), an integer encoding number, or DEFAULT
to use the default encoding.
-O, —owner
The name of the database user who will own the new database. Defaults to the user executing this command.
-T, —template
The name of the template from which to create the new database. Defaults to -h, —host The host name of the machine on which the HAWQ master database server is running. If not specified, reads from the environment variable -p, —port The TCP port on which the HAWQ master database server is listening for connections. If not specified, reads from the environment variable -U, —username The database role name to connect as. If not specified, reads from the environment variable -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 -W, —password Force a password prompt. Other Options --help Displays the online help. --version Displays the version of this utility. To create the database To create the database template1
.PGHOST
or defaults to localhost.PGPORT
or defaults to 5432.PGUSER
or defaults to the current system role name..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.Examples
testdb
using the default options:$ createdb testdb
demo
using the HAWQ master on host gpmaster
, port 54321
, using the LATIN1
encoding scheme:$ createdb -p 54321 -h gpmaster -E LATIN1 demo