A database is a collection of tables, indexes, views, stored procedures, and operators. You can create more than one database in an AnalyticDB for PostgreSQL instance. However, one client program can only connect to and access one database at a time. This means that you cannot query data across databases.

Create a database

Execute the CREATE DATABASE statement to create a database. The syntax is as follows:
CREATE DATABASE <dbname> [ [WITH] [OWNER [=] <dbowner>]
                      [ENCODING [=] <encoding>] 

Parameter description:

  • <dbname>: the name of the database you want to create.
  • <dbowner>: the username of the account who owns the database. By default, the user who executes the statement owns the database.
  • <encoding>: the character set encoding to use in the database. You must specify a string constant (such as 'SQL_ASCII') and an integer code number (UTF-8 by default).

Example:

CREATE DATABASE mygpdb;

Delete a database

Execute the DROP DATABASE statement to delete a database. This statement deletes the metadata of the database along with the directory of the database on the disk and the data contained in the database. The syntax is as follows:
DROP DATABASE <dbname>

Parameter description:

<dbname>: the name of the database you want to delete.

Example:
DROP DATABASE mygpdb;

References

For more information, visit Pivotal Greenplum documentation.