OceanBase logo

OceanBase

A unified distributed database ready for your transactional, analytical, and AI workloads.

DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Resources

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS

OceanBase Cloud

OceanBase Database

Tools

Connectors and Middleware

QUICK START

OceanBase Cloud

OceanBase Database

BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Company

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

International - English
中国站 - 简体中文
日本 - 日本語
Sign In
Start on Cloud

A unified distributed database ready for your transactional, analytical, and AI workloads.

DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS
OceanBase CloudOceanBase Database
ToolsConnectors and Middleware
QUICK START
OceanBase CloudOceanBase Database
BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

Start on Cloud
编组
All Products
    • Databases
    • iconOceanBase Database
    • iconOceanBase Cloud
    • iconOceanBase Tugraph
    • iconInteractive Tutorials
    • iconOceanBase Best Practices
    • Tools
    • iconOceanBase Cloud Platform
    • iconOceanBase Migration Service
    • iconOceanBase Developer Center
    • iconOceanBase Migration Assessment
    • iconOceanBase Admin Tool
    • iconOceanBase Loader and Dumper
    • iconOceanBase Deployer
    • iconKubernetes operator for OceanBase
    • iconOceanBase Diagnostic Tool
    • iconOceanBase Binlog Service
    • Connectors and Middleware
    • iconOceanBase Database Proxy
    • iconEmbedded SQL in C for OceanBase
    • iconOceanBase Call Interface
    • iconOceanBase Connector/C
    • iconOceanBase Connector/J
    • iconOceanBase Connector/ODBC
    • iconOceanBase Connector/NET
icon

OceanBase Database

SQL - V4.2.0

    Download PDF

    OceanBase logo

    The Unified Distributed Database for the AI Era.

    Follow Us
    Products
    OceanBase CloudOceanBase EnterpriseOceanBase Community EditionOceanBase seekdb
    Resources
    DocsBlogLive DemosTraining & Certification
    Company
    About OceanBaseTrust CenterLegalPartnerContact Us
    Follow Us

    © OceanBase 2026. All rights reserved

    Cloud Service AgreementPrivacy PolicySecurity
    Contact Us
    Document Feedback
    1. Documentation Center
    2. OceanBase Database
    3. SQL
    4. V4.2.0
    iconOceanBase Database
    SQL - V 4.2.0
    SQL
    KV
    • V 4.4.2
    • V 4.3.5
    • V 4.3.3
    • V 4.3.1
    • V 4.3.0
    • V 4.2.5
    • V 4.2.2
    • V 4.2.1
    • V 4.2.0
    • V 4.1.0
    • V 4.0.0
    • V 3.1.4 and earlier

    Create a DBLink

    Last Updated:2023-12-08 07:13:36  Updated
    share
    What is on this page
    Prerequisites
    Create a DBLink from an OceanBase database to another OceanBase database
    Create a DBLink from an OceanBase database to an Oracle database
    References

    folded

    share

    OceanBase Database provides DBLinks to support cross-data source access. You can use a DBLink to access a remote database from your local database.

    In the Oracle mode of OceanBase Database, you can create a DBLink between two Oracle tenants of OceanBase Database or between an Oracle tenant of OceanBase Database to an Oracle database.

    Prerequisites

    To create a DBLink, you must have the CREATE DATABASE LINK or CREATE PUBLIC DATABASE LINK privilege. For information about how to grant user privileges, see Modify user privileges.

    Create a DBLink from an OceanBase database to another OceanBase database

    To access a remote OceanBase database, you can create a DBLink from an Oracle tenant in your local OceanBase database to an Oracle tenant of the remote OceanBase database.

    To create a DBLink, you must specify the DBLink name and provide information, such as the username, tenant name, password, IP address, port number, and access type, of the remote database. The data write feature of DBLink supports reverse links. The remote database can access objects, such as tables, views, and synonyms, in the local database through a reverse link. To use the reverse link feature, you must provide information, such as the username, tenant name, password, IP address, and port number, of the local database when you create a DBLink.

    The SQL syntax for creating a DBLink from one Oracle tenant of OceanBase Database to another is as follows:

    obclient> CREATE DATABASE LINK dblink_name CONNECT TO user@tenant IDENTIFIED BY password [OB] HOST 'ip:port' [CLUSTER cluster_name]
           [MY_NAME local_user@local_tenant IDENTIFIED BY local_password HOST 'local_ip:local_port' [CLUSTER local_cluster_name]];
    

    where

    • dblink_name specifies the name of the DBLink. The value can contain a maximum of 128 characters.

    • user specifies the username for logging on to the remote OceanBase database.

    • tenant specifies the tenant name of the remote OceanBase database. Only Oracle tenants are supported.

    • password specifies the password for logging on to the remote OceanBase database. If the password contains a special character, such as @, #, or !, you must enclose the password with double quotation marks ("") to avoid syntax errors.

    • OB specifies that the type of the remote database is OceanBase. This parameter is optional.

      If this parameter is not specified, the remote database is an OceanBase database.

    • ip specifies the IP address of the remote OceanBase database. It can be the IP address of the OceanBase Database Proxy (ODP) for the cluster or the IP address of an OBServer node in the cluster.

      If the IP address of an OBServer node is specified, network connectivity must be ensured between the local database and the specified OBServer node.

    • port specifies the port of the remote OceanBase database. It can be the port of the ODP for the cluster, which is 2883 by default, or the SQL port of an OBServer node in the cluster, which is 2881 by default.

      If the SQL port of an OBServer node is specified, network connectivity must be ensured between the local database and the specified OBServer node.

    • cluster_name specifies the name of the cluster on the remote OceanBase database. You need to specify the cluster name only when the specified IP address and port number are those of the ODP of the cluster and the ODP is deployed by using ConfigUrl. The cluster name is case-sensitive and must be enclosed with double quotation marks ("").

      Note

      You can deploy a proxy such as ODP for a cluster by using the ConfigURL or RootService list.

      • ConfigUrl: When ODP is started, the obproxy_config_server_url parameter specified in the command is used to query the RootServer information of the OceanBase cluster.
      • RoortService list: When ODP is started, the -r parameter specified in the command is used to query the RootServer information of the OceanBase cluster.
    • [MY_NAME local_user@local_tenant IDENTIFIED BY local_password HOST 'local_ip:local_port' [CLUSTER local_cluster_name]] specifies the username, tenant name, password, IP address, port number, and cluster of the local database, which are required only if you want to use the reverse link feature of DBLink.

      • local_user: the username of the local database.

      • local_tenant: the name of the tenant to which the local database belongs.

      • local_password: the password used to log on to the local database. If the password contains a special character, such as @, #, or !, you must enclose the password with double quotation marks ("") to avoid syntax errors.

      • local_ip: the IP address of an OBServer node in the cluster of the local database.

      • local_port: the SQL port number of an OBServer node in the cluster of the local database. By default, the SQL port number of the OBServer node is 2881.

      • local_cluster_name: the name of the cluster of the local OceanBase database. You need to specify the cluster name only when the specified IP address and port number are those of the ODP of the cluster and the ODP is deployed by using ConfigUrl. The cluster name must be enclosed with double quotation marks ("").

    Here is an example:

    • Create a DBLink to connect to a remote OceanBase database by using the IP address and port number of the specified OBServer node.

      obclient> CREATE DATABASE LINK ob_dblink CONNECT TO ob_user@oracle IDENTIFIED BY ****** OB HOST 'xx.xx.xx.xx:2881';
      Query OK, 1 row affected
      
    • Create a DBLink to connect to a remote OceanBase database by using the IP address and port number of the ODP of a cluster. The ODP is deployed by using ConfigUrl.

      obclient> CREATE DATABASE LINK ob_dblink_proxy CONNECT TO ob_user@oracle IDENTIFIED BY ****** OB HOST 'xx.xx.xx.xx:2883' CLUSTER "ob410";
      Query OK, 1 row affected
      

      Notice

      Enclose the cluster name with double quotation marks ("") to prevent the cluster name from being capitalized.

    • Create a DBLink named ob_dblink_reverse_link that connects to a remote OceanBase database and provides the reverse link feature.

      
      obclient> CREATE DATABASE LINK ob_dblink_reverse_link CONNECT TO ob_user2@oracle IDENTIFIED BY ****** OB HOST  'xx.xx.xx.xx:2881' MY_NAME local_ob_user@oracle IDENTIFIED BY ****** HOST 'xx.xx.xx.xx:2881';
      Query OK, 1 row affected
      

    Create a DBLink from an OceanBase database to an Oracle database

    To access a remote Oracle database, you can create a DBLink from an Oracle tenant in your local OceanBase database to the remote Oracle database.

    To create a DBLink, you must specify the DBLink name and provide information, such as the username, tenant name, password, IP address, port number, and access type, of the remote database. The data write feature of DBLink supports reverse links. The remote database can access objects, such as tables, views, and synonyms, in the local database through a reverse link. The DBLink from an OceanBase database to an Oracle database does not support reverse links.

    The SQL syntax for creating a DBLink from an OceanBase database to an Oracle database is as follows:

    obclient> CREATE DATABASE LINK dblink_name CONNECT TO user@oracle IDENTIFIED BY password OCI HOST 'ip:port/oracle_service_name';
    

    where

    • dblink_name specifies the name of the DBLink. The value can contain a maximum of 128 characters.

    • user specifies the username for logging on to the remote Oracle database.

    • oracle is always used if the remote database is an Oracle database.

    • password specifies the password for logging on to the remote Oracle database. If the password contains a special character, such as @, #, or !, you must enclose the password with double quotation marks ("") to avoid syntax errors.

    • OCI indicates that the type of the remote database is Oracle. If this parameter is not specified, the remote database type is OceanBase by default.

    • ip specifies the IP address of the remote Oracle Database instance.

    • port specifies the port number of the remote Oracle Database instance.

    • oracle_service_name specifies the name of the service provided by the remote Oracle Database instance.

    Example: Create a DBLink to connect to a remote Oracle database:

    obclient> CREATE DATABASE LINK orcl_dblink CONNECT TO orcl_user@oracle IDENTIFIED BY ****** OCI HOST 'xx.xx.xx.xx:1521/ORCL';
    Query OK, 1 row affected
    

    References

    For more information about operations on DBLinks, see the following topics:

    • Query existing DBLinks

    • Use a DBLink to access data in a remote database

    • Use a DBLink to modify data in a remote database

    • Drop a DBLink

    Previous topic

    Manage directory objects
    Last

    Next topic

    Query existing DBLinks
    Next
    What is on this page
    Prerequisites
    Create a DBLink from an OceanBase database to another OceanBase database
    Create a DBLink from an OceanBase database to an Oracle database
    References