All Products
Search
Document Center

PolarDB:CreateDBLink

Last Updated:Jun 17, 2024

Creates a database link.

Operation description

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.

    Authorization information

    The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

    • Operation: the value that you can use in the Action element to specify the operation on a resource.
    • Access level: the access level of each operation. The levels are read, write, and list.
    • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
      • The required resource types are displayed in bold characters.
      • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
    • Condition Key: the condition key that is defined by the cloud service.
    • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
    OperationAccess levelResource typeCondition keyAssociated operation
    polardb:CreateDBLinkWrite
    • All Resources
      *
      none
    none

    Request parameters

    ParameterTypeRequiredDescriptionExample
    ResourceGroupIdstringNo

    The ID of the resource group.

    rg-************
    DBClusterIdstringYes

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

    Note You can call the DescribeDBClusters operation to query PolarDB clusters.
    pc-a************
    DBLinkNamestringYes

    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.
    dblink_test
    TargetDBInstanceNamestringYes

    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.
  • pc-b************
    TargetDBAccountstringYes

    The account of the destination database.

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

    The account password of the destination database.

    Test1111
    TargetDBNamestringYes

    The name of the destination database.

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

    The name of the source database.

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

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

    192.**.**.46
    TargetPortstringNo

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

    1521
    VpcIdstringNo

    The ID of the virtual private cloud (VPC).

    Note You can call the DescribeVpcs operation to query information about VPCs.
    vpc-bp1qpo0kug3a20qqe****
    RegionIdstringNo

    The ID of the region.

    Note You can call the DescribeRegions operation to query information about regions.
    cn-hangzhou
    ClientTokenstringNo

    The client token that is used to ensure the idempotence of the request. You can use the client to generate the value, but you must make sure that it is unique among different requests. The token can only contain ASCII characters and cannot exceed 64 characters in length. The token is case-sensitive.

    6000170000591aed949d0f54a343f1a4233c1e7d1c5c******

    Response parameters

    ParameterTypeDescriptionExample
    object
    RequestIdstring

    The ID of the request.

    F9F1CB1A-B1D5-4EF5-A53A-************

    Examples

    Sample success responses

    JSONformat

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

    Error codes

    HTTP status codeError codeError messageDescription
    400InvalidDBLinkName.MalformedThe specified parameter DBLinkName is not valid.The specified DBLinkName parameter is invalid.
    404InvalidDBClusterId.NotFoundThe DBClusterId provided does not exist in our records.The specified DBClusterId parameter does not exist in the current record.
    404DBLinkSourceDBNotFoundSpecified source db does not exist.The specified source database does not exist.

    For a list of error codes, visit the Service error codes.

    Change history

    Change timeSummary of changesOperation
    2023-09-12The Error code has changedsee changesets
    Change itemChange content
    Error CodesThe Error code has changed.
      Error Codes 404 change
      Added Error Codes: 400