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
CREATE DATABASEstatement to create a database. The syntax is as follows:
CREATE DATABASE <dbname> [ [WITH] [OWNER [=] <dbowner>] [ENCODING [=] <encoding>]
- <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).
CREATE DATABASE mygpdb;
Delete a database
DROP DATABASEstatement 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>
<dbname>: the name of the database you want to delete.
DROP DATABASE mygpdb;
For more information, visit Pivotal Greenplum documentation.