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.
- 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
Request parameters
Parameter | Type | Required | Example | Description |
---|---|---|---|---|
Action | String | No | CreateDBLink | The operation that you want to perform. Set the value to CreateDBLink. |
ResourceGroupId | String | No | rg-************ | The ID of the resource group. |
DBClusterId | String | Yes | pc-a************ | The ID of the source cluster that the database link connects. |
DBLinkName | String | Yes | dblink_test | The name of the database link.
|
TargetDBInstanceName | String | Yes | pc-b************ | The ID of the destination cluster that the database link connects. Note
|
TargetDBAccount | String | Yes | testacc | The account of the destination database. |
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). |
RegionId | String | No | cn-hangzhou | The ID of the region. |
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.