After you create a DBLink, you can query its information from views, including the user who created the DBLink, name of the DBLink, and IP address and port number of the remote database.
Procedure
After you create a DBLink, you can query the DBA_DB_LINKS view for its information.
SELECT * FROM oceanbase.DBA_DB_LINKS;
The query result is as follows:
+--------+-----------+----------+-----------------+------------------+---------------------+---------------------+--------+----------------+-------+-----------+-------------+---------------+---------------------+--------------+----------------------+--------------+--------------+
| OWNER | DB_LINK | USERNAME | CREDENTIAL_NAME | CREDENTIAL_OWNER | HOST | CREATED | HIDDEN | SHARD_INTERNAL | VALID | INTRA_CDB | TENANT_NAME | DATABASE_NAME | REVERSE_TENANT_NAME | CLUSTER_NAME | REVERSE_CLUSTER_NAME | REVERSE_HOST | REVERSE_PORT |
+--------+-----------+----------+-----------------+------------------+---------------------+---------------------+--------+----------------+-------+-----------+-------------+---------------+---------------------+--------------+----------------------+--------------+--------------+
| PUBLIC | ob_dblink | test | | | xx.xx.xx.xx:2881 | 2023-05-25 13:40:35 | | | YES | | mysql001 | mydb | | | | 0.0.0.0 | 0 |
+--------+-----------+----------+-----------------+------------------+---------------------+---------------------+--------+----------------+-------+-----------+-------------+---------------+---------------------+--------------+----------------------+--------------+--------------+
1 row in set
Columns in the query result are described as follows:
OWNER: the owner of the DBLink. At present, all DBLinks are public and can be used by all users in the tenant.DB_LINK: the name of the DBLink.USERNAME: the username used to connect to the remote database by using the DBLink.HOST: the hostname (or IP address) used to connect to the remote database by using the DBLink.CREATED: the time when the DBLink was created.VALID: indicates whether the DBLink is available. This column is used only for compatibility. The default value isYES.TENANT_NAME: the tenant name used to connect to the remote database by using the DBLink.DATABASE_NAME: the name of the remote database that the DBLink connects to.REVERSE_HOST: the tenant name used to connect to the local database from the remote database by using the DBLink. At present, the reverse link feature is not supported in MySQL mode.CLUSTER_NAME: the cluster name used to connect to the remote database by using the DBLink.REVERSE_CLUSTER_NAME: the cluster name used to connect to the local database from the remote database by using the DBLink. At present, the reverse link feature is not supported in MySQL mode.REVERSE_HOST: the hostname (or IP address) used to connect to the local database from the remote database by using the DBLink. If the current DBLink does not support the reverse link feature, the value is0.0.0.0. At present, the reverse link feature is not supported in MySQL mode.REVERSE_PORT: the port number used to connect to the local database from the remote database by using the DBLink. If the current DBLink does not support the reverse link feature, the value is0. At present, the reverse link feature is not supported in MySQL mode.
For more information about fields in the DBA_DB_LINKS view, see DBA_DB_LINKS.
References
For more information about operations on DBLinks, see the following topics: