Creates a database link.

A database link can be used to connect two PolarDB for PostgreSQL(Compatible with Oracle) clusters, or connect a PolarDB for PostgreSQL(Compatible with Oracle) cluster to a user-created PostgreSQL database that is hosted on an Elastic Compute Service (ECS) instance. You can use database links to query data across clusters.

Note
  • You can create up to 10 database links for a cluster.
  • Each database link connects a source cluster and a destination cluster.
  • The source cluster and the destination cluster or the destination ECS instance must be located in the same region.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

ParameterTypeRequiredExampleDescription
ActionStringNoCreateDBLink

The operation that you want to perform. Set the value to CreateDBLink.

ResourceGroupIdStringNorg-************

The ID of the resource group.

DBClusterIdStringYespc-a************

The ID of the source cluster that the database link connects.

Note You can call the DescribeDBClusters operation to query PolarDB clusters.
DBLinkNameStringYesdblink_test

The name of the database link.

  • The name must contain lowercase letters and can also contain digits and underscores (_).
  • The name must start with a letter and end with a letter or digit.
  • The name must be 1 to 64 characters in length.
TargetDBInstanceNameStringYespc-b************

The ID of the destination cluster that the database link connects.

Note
  • If the destination cluster is a user-created Oracle database on an ECS instance, set the value to null.
  • You can call the DescribeDBClusters operation to query PolarDB clusters.
TargetDBAccountStringYestestacc

The account of the destination database.

Note You can call the DescribeAccounts operation to query the account of a PolarDB cluster.
TargetDBPasswdStringYesTest1111

The account password of the destination database.

TargetDBNameStringYestestdb2

The name of the destination database.

Note You can call the DescribeDatabases operation to query information about databases in a PolarDB cluster.
SourceDBNameStringYestestdb1

The name of the source database.

Note You can call the DescribeDatabases operation to query information about databases in a PolarDB cluster.
TargetIpStringNo192.**. **.46

The IP address of the user-created Oracle database on an ECS instance.

TargetPortStringNo1521

The port number of the user-created Oracle database on an ECS instance.

VpcIdStringNovpc-bp1qpo0kug3a20qqe****

The ID of the virtual private cloud (VPC).

Note You can call the DescribeVpcs operation to query information about VPCs.
RegionIdStringNocn-hangzhou

The ID of the region.

Note You can call the DescribeRegions operation to query information about regions.

Response parameters

ParameterTypeExampleDescription
RequestIdStringF9F1CB1A-B1D5-4EF5-A53A-************

The ID of the request.

Examples

Sample requests

http(s)://polardb.aliyuncs.com/? Action=CreateDBLink
&DBClusterId=pc-a************
&DBLinkName=dblink_test
&TargetDBInstanceName=pc-b************
&TargetDBAccount=testacc
&TargetDBPasswd=Test1111
&TargetDBName=testdb2
&SourceDBName=testdb1
&<Common request parameters>

Sample success responses

XML format

<CreateDBLinkResponse>
      <RequestId>F9F1CB1A-B1D5-4EF5-A53A-************</RequestId>
</CreateDBLinkResponse>

JSON format

{
    "RequestId":"F9F1CB1A-B1D5-4EF5-A53A-************"
}

Error codes

For a list of error codes, visit the API Error Center.