Creates a database link.

A database link can be used to connect two PolarDB-O clusters, or connect a PolarDB-O cluster to a user-created Oracle 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

Parameter Type Required Example Description
Action String No CreateDBLink

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

DBClusterId String Yes pc-a************

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

Note You can call the DescribeDBClusters operation to query PolarDB clusters.
DBLinkName String Yes dblink_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.
TargetDBInstanceName String Yes pc-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.
TargetDBAccount String Yes testacc

The account of the destination database.

Note You can call the DescribeAccounts operation to query the account of a PolarDB cluster.
TargetDBPasswd String Yes Test1111

The account password of the destination database.

TargetDBName String Yes testdb2

The name of the destination database.

Note You can call the DescribeDatabases operation to query information about databases in a PolarDB cluster.
SourceDBName String Yes testdb1

The name of the source database.

Note You can call the DescribeDatabases operation to query information about databases in a PolarDB cluster.
TargetIp String No 192.**. **.46

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

TargetPort String No 1521

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

VpcId String No vpc-bp1qpo0kug3a20qqe****

The ID of the virtual private cloud (VPC).

Note You can call the DescribeVpcs operation to query information about VPCs.
RegionId String No cn-hangzhou

The ID of the region.

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

Response parameters

Parameter Type Example Description
RequestId String F9F1CB1A-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.