Create databases

This page describes how to create an Autonomous Database in Google Cloud.

In Oracle Database@Google Cloud, you can create an Autonomous Database in the Google Cloud using Google Cloud console or the Oracle Database@Google Cloud API. To see which regions you can create Autonomous Database resources in, see Available configurations.

Before you begin

Create an Autonomous Database

Console

  1. Go to the Autonomous Database Service page in the Google Cloud console.

    Go to Autonomous Database Service

  2. Click Create.

  3. In the Instance details section, complete the following:

    1. Enter an Instance ID for your database. This field is permanent and can't be modified once created.

    2. Enter a Database name for your database. The database name must meet the following criteria:

      • Only contain letters and numbers
      • Must start with a letter
      • Can't exceed the maximum limit of 30 characters
    3. Enter a Database display name to help identify your database.

    4. Select a Region for your database from the drop-down. The region choice is permanent and can't be changed later.

    5. Confirm your Oracle Cloud account. If the account name doesn't match your Oracle Cloud account, confirm that you're in the correct project for your database.

  4. In the Workload configuration section, choose one of the following workload types for your database:

    • Data Warehouse: select the data warehouse if you're looking for fast queries over large volumes of data. This is built for data warehouse workloads.

    • Transaction Processing: select transaction processing if you're looking for high concurrency for short-running queries and transactions. This is built for transactional workloads.

    • JSON: select JSON if you're looking for JSON-centric application development that has built-in JSON storage.

    • APEX: select APEX if you're looking for a warehouse built for Oracle APEX application development with creation and deployment of low-code application.

  5. In the Database configuration section, complete the following:

    1. Select your License type from the drop-down. If you choose Bring Your Own License (BYOL), then select the edition from the Oracle Database Edition drop-down.

    2. Select a database version in the Choose database version drop-down.

    3. In the ECPU count field, enter your preferred count. The EPCU count can range from 2 to 512.

      Select the Enable compute autoscaling checkbox to let the system to expand the specific ECPU count up to three times if the demand increases. This is an optional field.

    4. In the Storage (TB) field, enter your preferred storage count. Storage can range from .02 TB to 384 TB and is measured in gigabyte (GB) increments.

      For Data Warehouse workloads only, storage is measured in terabyte (TB) increments and must range from 1 TB to 384 TB.

      Select the Enable storage autoscaling checkbox to let the system to expand the reserved storage up to three times. This is an optional field.

  6. In the Backup retention section, enter the retention period for backups in the Backup retention period in days field. This number can range from 1 to 60 days.

    Backups beyond the set retention period are automatically deleted. Automatic backups are managed by Oracle and billed separately, in addition to database storage.

  7. In the Administrator credentials section, confirm the administrator username and enter your password in the Password field. Re-enter your password in the Confirm password field to confirm.

  8. In the Networking section, define the network configuration for the Autonomous Database by completing the following:

    1. In the Associated network drop-down, select the network you want to use. You can only choose one network from the list.

    2. In the Configure networking for your database section, enter the IPv4 subnet range for your Autonomous Database. The database subnet range can't overlap with the subnet range of the VPC network project you're using. IPv6 addresses aren't supported.

      Address ranges must use a valid CIDR notation (for example, 10.10.10.0/24). For more information on how to select client IP ranges, see Requirements for IP Address space.

    3. In the Advanced network settings section, you can optionally provide a Private IP address or a Hostname prefix.

      Check the Require mutual TLS (mTLS) authentication box if you want to require mTLS to authenticate connections to your Autonomous Database.

  9. In the Operational notifications and announcements contact section, enter the email addresses for all contacts you want to receive notifications about this database.

  10. In the Advanced settings section, you can optionally modify the following settings:

    1. Maintenance: this setting is set to Regular by default, which patches your database on a regular schedule. You can modify this setting to Early which patches your database one week before the regular scheduled patch maintenance.

    2. Management: this setting sets AL32UTF8 as the default for the Character set and AL16UTF16 as the default for National character set. Use the drop-downs to modify these settings as necessary.

      Note that the AL32UTF8 value is recommended by default for Character set.

  11. Click Create to create your database.

gcloud

Use the gcloud oracle-database autonomous-databases create command to create a database.

gcloud oracle-database autonomous-databases create DATABASE_ID
--location=REGION_ID
--display-name=DISPLAY_NAME
--network=NETWORK_PROJECT_NAME
--database=DATABASE_NAME
--admin-password=ADMIN_PASSWORD
--cidr=CIDR_RANGE
--properties-compute-count=COMPUTE_COUNT
--properties-db-version=DATABASE_VERSION
--properties-license-type=LICENSE_TYPE
--properties-db-workload=WORKLOAD_TYPE

Replace the following:

  • DATABASE_ID: a permanent identifier for your instance. The database ID can't be changed once set.
  • REGION_ID: the region for your database. The region is permanent and can't be changed later. For a list of available regions, see Available configurations.
  • DISPLAY_NAME: a name to identify your database. This name is displayed in the Google Cloud console. The name must be unique within your Google Cloud project.
  • NETWORK_PROJECT_NAME: the name of the network from your network VPC project that you'd like to use for your cluster. The name must use following format:

    projects/PROJECT_ID/locations/global/NETWORK_NAME
    

    To create a VPC network project, see Configure VPC network.

  • DATABASE: the name of your Autonomous Database. The name must be unique within your project, must begin with a letter, and can only contain a maximum of 30 alphanumeric characters.

  • ADMIN_PASSWORD: the password for the default administrator user for your Autonomous Database.

  • CIDR_RANGE: the subnet range for your Autonomous Database. The subnet range must use CIDR notation, be IPv4 only, and not overlap with the subnet range of your Google Cloud network project.

  • COMPUTE_COUNT: the compute capacity for your database.

  • DATABASE_VERSION: the Oracle database version for your database.

  • WORKLOAD_TYPE: the workload type for your Autonomous Database that must be one of the following:

    • ajd: Autonomous JSON Database
    • apex: Autonomous Database with Oracle APEX Application Development workload type
    • dw: Autonomous Data Warehouse database
    • oltp: Autonomous Transaction Processing database

C#

using Google.Cloud.OracleDatabase.V1;
using Google.LongRunning;
using System.Threading.Tasks;

public sealed partial class GeneratedOracleDatabaseClientSnippets
{
    /// <summary>Snippet for CreateAutonomousDatabaseAsync</summary>
    /// <remarks>
    /// This snippet has been automatically generated and should be regarded as a code template only.
    /// It will require modifications to work:
    /// - It may require correct/in-range values for request initialization.
    /// - It may require specifying regional endpoints when creating the service client as shown in
    ///   https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint.
    /// </remarks>
    public async Task CreateAutonomousDatabaseAsync()
    {
        // Create client
        OracleDatabaseClient oracleDatabaseClient = await OracleDatabaseClient.CreateAsync();
        // Initialize request argument(s)
        string parent = "projects/[PROJECT]/locations/[LOCATION]";
        AutonomousDatabase autonomousDatabase = new AutonomousDatabase();
        string autonomousDatabaseId = "";
        // Make the request
        Operation<AutonomousDatabase, OperationMetadata> response = await oracleDatabaseClient.CreateAutonomousDatabaseAsync(parent, autonomousDatabase, autonomousDatabaseId);

        // Poll until the returned long-running operation is complete
        Operation<AutonomousDatabase, OperationMetadata> completedResponse = await response.PollUntilCompletedAsync();
        // Retrieve the operation result
        AutonomousDatabase result = completedResponse.Result;

        // Or get the name of the operation
        string operationName = response.Name;
        // This name can be stored, then the long-running operation retrieved later by name
        Operation<AutonomousDatabase, OperationMetadata> retrievedResponse = await oracleDatabaseClient.PollOnceCreateAutonomousDatabaseAsync(operationName);
        // Check if the retrieved long-running operation has completed
        if (retrievedResponse.IsCompleted)
        {
            // If it has completed, then access the result
            AutonomousDatabase retrievedResult = retrievedResponse.Result;
        }
    }
}

Go


package main

import (
	"context"

	oracledatabase "cloud.google.com/go/oracledatabase/apiv1"
	oracledatabasepb "cloud.google.com/go/oracledatabase/apiv1/oracledatabasepb"
)

func main() {
	ctx := context.Background()
	// This snippet has been automatically generated and should be regarded as a code template only.
	// It will require modifications to work:
	// - It may require correct/in-range values for request initialization.
	// - It may require specifying regional endpoints when creating the service client as shown in:
	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
	c, err := oracledatabase.NewRESTClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &oracledatabasepb.CreateAutonomousDatabaseRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/oracledatabase/apiv1/oracledatabasepb#CreateAutonomousDatabaseRequest.
	}
	op, err := c.CreateAutonomousDatabase(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}

	resp, err := op.Wait(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

Java

import com.google.api.core.ApiFuture;
import com.google.cloud.oracledatabase.v1.AutonomousDatabase;
import com.google.cloud.oracledatabase.v1.CreateAutonomousDatabaseRequest;
import com.google.cloud.oracledatabase.v1.LocationName;
import com.google.cloud.oracledatabase.v1.OracleDatabaseClient;
import com.google.longrunning.Operation;

public class AsyncCreateAutonomousDatabase {

  public static void main(String[] args) throws Exception {
    asyncCreateAutonomousDatabase();
  }

  public static void asyncCreateAutonomousDatabase() throws Exception {
    // This snippet has been automatically generated and should be regarded as a code template only.
    // It will require modifications to work:
    // - It may require correct/in-range values for request initialization.
    // - It may require specifying regional endpoints when creating the service client as shown in
    // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
    try (OracleDatabaseClient oracleDatabaseClient = OracleDatabaseClient.create()) {
      CreateAutonomousDatabaseRequest request =
          CreateAutonomousDatabaseRequest.newBuilder()
              .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
              .setAutonomousDatabaseId("autonomousDatabaseId-1972693114")
              .setAutonomousDatabase(AutonomousDatabase.newBuilder().build())
              .setRequestId("requestId693933066")
              .build();
      ApiFuture<Operation> future =
          oracleDatabaseClient.createAutonomousDatabaseCallable().futureCall(request);
      // Do something.
      Operation response = future.get();
    }
  }
}

Node.js

/**
 * This snippet has been automatically generated and should be regarded as a code template only.
 * It will require modifications to work.
 * It may require correct/in-range values for request initialization.
 * TODO(developer): Uncomment these variables before running the sample.
 */
/**
 *  Required. The name of the parent in the following format:
 *  projects/{project}/locations/{location}.
 */
// const parent = 'abc123'
/**
 *  Required. The ID of the Autonomous Database to create. This value is
 *  restricted to (^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$) and must be a maximum of
 *  63 characters in length. The value must start with a letter and end with a
 *  letter or a number.
 */
// const autonomousDatabaseId = 'abc123'
/**
 *  Required. The Autonomous Database being created.
 */
// const autonomousDatabase = {}
/**
 *  Optional. An optional ID to identify the request. This value is used to
 *  identify duplicate requests. If you make a request with the same request ID
 *  and the original request is still in progress or completed, the server
 *  ignores the second request. This prevents clients from
 *  accidentally creating duplicate commitments.
 *  The request ID must be a valid UUID with the exception that zero UUID is
 *  not supported (00000000-0000-0000-0000-000000000000).
 */
// const requestId = 'abc123'

// Imports the Oracledatabase library
const {OracleDatabaseClient} = require('@google-cloud/oracledatabase').v1;

// Instantiates a client
const oracledatabaseClient = new OracleDatabaseClient();

async function callCreateAutonomousDatabase() {
  // Construct request
  const request = {
    parent,
    autonomousDatabaseId,
    autonomousDatabase,
  };

  // Run request
  const [operation] = await oracledatabaseClient.createAutonomousDatabase(request);
  const [response] = await operation.promise();
  console.log(response);
}

callCreateAutonomousDatabase();

PHP

use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\OracleDatabase\V1\AutonomousDatabase;
use Google\Cloud\OracleDatabase\V1\Client\OracleDatabaseClient;
use Google\Cloud\OracleDatabase\V1\CreateAutonomousDatabaseRequest;
use Google\Rpc\Status;

/**
 * Creates a new Autonomous Database in a given project and location.
 *
 * @param string $formattedParent                    The name of the parent in the following format:
 *                                                   projects/{project}/locations/{location}. Please see
 *                                                   {@see OracleDatabaseClient::locationName()} for help formatting this field.
 * @param string $autonomousDatabaseId               The ID of the Autonomous Database to create. This value is
 *                                                   restricted to (^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$) and must be a maximum of
 *                                                   63 characters in length. The value must start with a letter and end with a
 *                                                   letter or a number.
 * @param string $formattedAutonomousDatabaseNetwork The name of the VPC network used by the Autonomous Database in
 *                                                   the following format: projects/{project}/global/networks/{network}
 *                                                   Please see {@see OracleDatabaseClient::networkName()} for help formatting this field.
 * @param string $autonomousDatabaseCidr             The subnet CIDR range for the Autonmous Database.
 */
function create_autonomous_database_sample(
    string $formattedParent,
    string $autonomousDatabaseId,
    string $formattedAutonomousDatabaseNetwork,
    string $autonomousDatabaseCidr
): void {
    // Create a client.
    $oracleDatabaseClient = new OracleDatabaseClient();

    // Prepare the request message.
    $autonomousDatabase = (new AutonomousDatabase())
        ->setNetwork($formattedAutonomousDatabaseNetwork)
        ->setCidr($autonomousDatabaseCidr);
    $request = (new CreateAutonomousDatabaseRequest())
        ->setParent($formattedParent)
        ->setAutonomousDatabaseId($autonomousDatabaseId)
        ->setAutonomousDatabase($autonomousDatabase);

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $oracleDatabaseClient->createAutonomousDatabase($request);
        $response->pollUntilComplete();

        if ($response->operationSucceeded()) {
            /** @var AutonomousDatabase $result */
            $result = $response->getResult();
            printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
        } else {
            /** @var Status $error */
            $error = $response->getError();
            printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = OracleDatabaseClient::locationName('[PROJECT]', '[LOCATION]');
    $autonomousDatabaseId = '[AUTONOMOUS_DATABASE_ID]';
    $formattedAutonomousDatabaseNetwork = OracleDatabaseClient::networkName('[PROJECT]', '[NETWORK]');
    $autonomousDatabaseCidr = '[CIDR]';

    create_autonomous_database_sample(
        $formattedParent,
        $autonomousDatabaseId,
        $formattedAutonomousDatabaseNetwork,
        $autonomousDatabaseCidr
    );
}

Python

# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
#   client as shown in:
#   https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import oracledatabase_v1


def sample_create_autonomous_database():
    # Create a client
    client = oracledatabase_v1.OracleDatabaseClient()

    # Initialize request argument(s)
    autonomous_database = oracledatabase_v1.AutonomousDatabase()
    autonomous_database.network = "network_value"
    autonomous_database.cidr = "cidr_value"

    request = oracledatabase_v1.CreateAutonomousDatabaseRequest(
        parent="parent_value",
        autonomous_database_id="autonomous_database_id_value",
        autonomous_database=autonomous_database,
    )

    # Make the request
    operation = client.create_autonomous_database(request=request)

    print("Waiting for operation to complete...")

    response = operation.result()

    # Handle the response
    print(response)

Ruby

require "google/cloud/oracle_database/v1"

##
# Snippet for the create_autonomous_database call in the OracleDatabase service
#
# This snippet has been automatically generated and should be regarded as a code
# template only. It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in https://cloud.google.com/ruby/docs/reference.
#
# This is an auto-generated example demonstrating basic usage of
# Google::Cloud::OracleDatabase::V1::OracleDatabase::Rest::Client#create_autonomous_database.
#
def create_autonomous_database
  # Create a client object. The client can be reused for multiple calls.
  client = Google::Cloud::OracleDatabase::V1::OracleDatabase::Rest::Client.new

  # Create a request. To set request fields, pass in keyword arguments.
  request = Google::Cloud::OracleDatabase::V1::CreateAutonomousDatabaseRequest.new

  # Call the create_autonomous_database method.
  result = client.create_autonomous_database request

  # The returned object is of type Gapic::Operation. You can use it to
  # check the status of an operation, cancel it, or wait for results.
  # Here is how to wait for a response.
  result.wait_until_done! timeout: 60
  if result.response?
    p result.response
  else
    puts "No response received."
  end
end

What's next