Top
Enterprise Postgres 17 Operation Guide

2.2.2 Using Client Commands

Follow the procedure below to define a database using client commands.

An example of operations on the server is shown below.

  1. Use psql command to connect to the postgres database.
    Execute psql postgres.

    > psql postgres
    psql (<x>) (*1)
    Type "help" for help.

    *1: <x> indicates the PostgreSQL version on which this product is based.

  2. Create the database.
    To create the database, execute the CREATE DATABASE databaseName; statement.

    postgres=# CREATE DATABASE db01;
    CREATE DATABASE
  3. Confirm that the database is created.
    Execute \l+, and confirm that the name of the database created in step 2 is displayed.

    postgres=# \l+
  4. Disconnect from the postgres database.
    Execute \q to terminate the psql command.

    postgres=# \q

You can create a database using the createdb command.

See

Refer to "Creating a Database" in "Tutorial" in the PostgreSQL Documentation for information on creating a database using the createdb command.