Neon Deploy: Learn how Neon helps developers ship faster with Postgres. Grab your ticket

Neon CLI commands — databases

Use the Neon CLI to manage Neon directly from the terminal

Before you begin

  • Before running the databases command, ensure that you have installed the Neon CLI.
  • If you have not authenticated with the neon auth command, running a Neon CLI command automatically launches the Neon CLI browser authentication process. Alternatively, you can specify a Neon API key using the --api-key option when running a command. See Connect.

For information about databases in Neon, see Manage databases.

The databases command

Usage

The databases command allows you to list, create, and delete databases in a Neon project.

SubcommandDescription
listList databases
createCreate a database
deleteDelete a database

list

This subcommand allows you to list databases.

Usage

neon databases list [options]

Options

In addition to the Neon CLI global options, the list subcommand supports these options:

OptionDescriptionTypeRequired
--context-fileContext file path and file namestring
--project-idProject IDstringOnly if your Neon account has more than one project
--branchBranch ID or namestring

If a branch ID or name is not provided, the command lists databases for the default branch of the project.

Example

neon databases list --branch br-autumn-dust-190886
┌────────┬────────────┬──────────────────────┐
 Name Owner Name Created At
├────────┼────────────┼──────────────────────┤
 neondb daniel 2023-06-19T18:27:19Z
└────────┴────────────┴──────────────────────┘

create

This subcommand allows you to create a database.

Usage

neon databases create [options]

Options

In addition to the Neon CLI global options, the create subcommand supports these options:

OptionDescriptionTypeRequired
--context-fileContext file path and file namestring
--project-idProject IDstringOnly if your Neon account has more than one project
--branchBranch ID or namestring
--nameThe name of the databasestring
--owner-nameThe name of the role that owns the databasestring
  • If a branch ID or name is not provided, the command creates the database in the default branch of the project.
  • If the --owner-name option is not specified, the current user becomes the database owner.

Example

neon databases create --name mynewdb --owner-name john
┌─────────┬────────────┬──────────────────────┐
 Name Owner Name Created At
├─────────┼────────────┼──────────────────────┤
 mynewdb john 2023-06-19T23:45:45Z
└─────────┴────────────┴──────────────────────┘

delete

This subcommand allows you to delete a database.

Usage

neon databases delete <database> [options]

<database> is the database name.

Options

In addition to the Neon CLI global options, the delete subcommand supports these options:

OptionDescriptionTypeRequired
--context-fileContext file path and file namestring
--project-idProject IDstringOnly if your Neon account has more than one project
--branchBranch ID or namestring

If a branch ID or name is not provided, it is assumed the database resides in the default branch of the project.

Example

neon databases delete mydb
┌─────────┬────────────┬──────────────────────┐
 Name Owner Name Created At
├─────────┼────────────┼──────────────────────┤
 mydb daniel 2023-06-19T23:45:45Z
└─────────┴────────────┴──────────────────────┘

Need help?

Join our Discord Server to ask questions or see what others are doing with Neon. Users on paid plans can open a support ticket from the console. For more detail, see Getting Support.

Last updated on

Was this page helpful?