All Products
Search
Document Center

AnalyticDB:Manage databases

Last Updated:Mar 28, 2026

A database in AnalyticDB for PostgreSQL is a collection of tables, indexes, views, stored procedures, and operators. Each instance can contain multiple databases, but a client can connect to only one database at a time — cross-database queries are not supported.

Create a database

CREATE DATABASE <dbname> [ [WITH] [OWNER [=] <dbowner>] ]
                      [ENCODING [=] <encoding>]

Parameters:

ParameterDescriptionDefault
<dbname>Name of the database to create.
<dbowner>User who owns the database.The user who runs the statement.
<encoding>Character set encoding. Specify a string constant such as 'SQL_ASCII' or an integer code number.utf-8

Example:

CREATE DATABASE mygpdb;

Switch to another database

Use DMS

  1. Connect to a database using Data Management (DMS). For instructions, see DMS.

  2. In the left-side navigation pane, click Instances Connected.

  3. Find and expand the target instance.

  4. Expand the database you want to switch to, then double-click its schema.

Use psql

  1. Connect to a database using psql. For instructions, see psql.

  2. Run the following command:

    \c <databasename>

    Replace <databasename> with the name of the database to switch to.

Delete a database

Warning

DROP DATABASE permanently removes the database's metadata, the on-disk directory, and all data it contains. This operation cannot be undone.

DROP DATABASE <dbname>

Replace <dbname> with the name of the database to delete.

Example:

DROP DATABASE mygpdb;