Create a database (Java)

Creates a database.

To replicate a database to additional datacenters, see Deploy an Astra DB Serverless database to multiple regions.

You need an application token with permission to create and configure databases, such as the Organization Administrator role.

For more information, see Get endpoint and token.

Result

Creates a database and returns a DatabaseAdmin object that can perform administrative actions on the newly-created database.

Parameters

Use the createDatabase method, which belongs to the com.datastax.astra.client.admin.AstraDBAdmin class.

Method signature
DatabaseAdmin createDatabase(String name)
DatabaseAdmin createDatabase(
  String name,
  DatabaseDefinition definition,
  CreateDatabaseOptions options
)
DatabaseAdmin createDatabase(
  String name,
  DatabaseDefinition definition
)
DatabaseAdmin createDatabase(
  String name,
  CloudProviderType cloud,
  String cloudRegion
)
DatabaseAdmin createDatabase(
  String name,
  CloudProviderType cloud,
  String cloudRegion,
  boolean waitForDb
)
Name Type Summary

name

String

The name for the database.

Database names must follow these rules:

  • Must start and end with a letter or number

  • Can contain letters, numbers, and the special characters & + - _ ( ) < > . , @

  • Cannot exceed 50 characters

definition

DatabaseDefinition

The configuration for the database.

See Methods of DatabaseDefinition for more details.

options

CreateDatabaseOptions

The configuration for the database.

The options for this operation. See Methods of CreateDatabaseOptions for more details.

cloud

CloudProviderType

The cloud provider that should host the database.

Default (if you only specify the database name): gcp

cloudRegion

String

The cloud provider region in which to create the database.

The available regions depend on your Astra plan and the database type. To find available regions, see Find available regions (Java).

Default (if you only specify the database name): us-east1

waitForDb

boolean

Optional. Whether to wait for the database to become active before returning. If false, the method returns immediately after issuing the creation request, but you cannot work with the database until it becomes active.

Default: true

Methods of DatabaseDefinition
Method Parameters Summary

cloudProvider

CloudProviderType

The cloud provider that should host the database. Can be one of: aws, gcp, azure.

cloudRegion

String

The cloud provider region in which to create the database.

The available regions depend on your Astra plan and the database type. To find available regions, see Find available regions (Java).

keyspace

String

Optional. The name for the database’s initial keyspace.

Default: default_keyspace

PCUGroupId

UUID

Optional. The ID of the PCU group to use for provisioning the database. The specified PCU group must have the same cloud provider and region as the database. Only applicable for organizations that use PCU groups.

Default: No PCU group

dbType

String

To create a Serverless (vector) database, set this parameter to vector.

To create a Serverless (non-vector) database, set it to nonvector.

The Data API is supported for Serverless (vector) and Serverless (non-vector) databases generally. However, vector and reranking functionalities aren’t compatible with all databases, tables, or collections.

Default: vector

tier

String

Optional. The database tier.

If specified, must be serverless.

Default: serverless

capacityUnits

Integer

Optional. The number of capacity units for the database. This is unrelated to PCU group capacity.

If specified, must be 1.

Default: 1

Methods of CreateDatabaseOptions
Method Parameters Summary

waitForDb()

boolean

Optional. Whether to wait for the database to become active before returning. If false, the method returns immediately after issuing the creation request, but you cannot work with the database until it becomes active.

Default: true

Examples

The following examples demonstrate how to create a database.

import com.datastax.astra.client.DataAPIClient;
import com.datastax.astra.client.admin.AstraDBAdmin;
import com.datastax.astra.client.admin.definition.DatabaseDefinition;
import com.dtsx.astra.sdk.db.domain.CloudProviderType;

public class Example {
  public static void main(String[] args) {
    DataAPIClient client = new DataAPIClient("APPLICATION_TOKEN");

    AstraDBAdmin admin = client.getAdmin();

    DatabaseDefinition definition =
        DatabaseDefinition.builder()
            .cloudProvider(CloudProviderType.GCP)
            .region("us-east-1")
            .build();

    admin.createDatabase("DATABASE_NAME", definition, null);
  }
}

Client reference

For more information, see the client reference.

Was this helpful?

Give Feedback

How can we improve the documentation?

© Copyright IBM Corporation 2026 | Privacy policy | Terms of use Manage Privacy Choices

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: Contact IBM