跳到主要内容
版本:V1.1.0

getDatabase - 获取指定数据库

getDatabase() 用于获取指定数据库信息。

信息

仅支持在使用 SeekdbAdminClient 连接时,才能使用该接口。关于 SeekdbAdminClient 的详细介绍,参见 SeekdbAdminClient

前提条件

  • 您已经安装了 seekdb-js,有关安装 seekdb-js 的详细信息,参见 快速开始

  • 您已经安装了 seekdb 服务器模式,有关安装 seekdb 服务器模式的详细信息,参见 通过 yum install 部署 seekdb

  • 您已经连接到数据库。有关连接的详细操作参见 SeekdbAdminClient

请求参数

getDatabase(name: string, tenant?: string)
参数取值类型是否必选描述取值示例
namestring必选指定要查询的数据库的名称。my_database
tenantstring可选
  • 当使用服务器模式 seekdb 时,不需要填写该参数。
  • 当使用 OceanBase 数据库时,该参数必选。
指定所创建的数据库归属的租户。test_tenant

请求示例

import { SeekdbAdminClient } from "seekdb";

// 远程服务器模式 - 数据库管理 (seekdb Server)
const admin = new SeekdbAdminClient({
host: "127.0.0.1",
port: 2881,
user: "root",
password: ""
});

const db = await admin.getDatabase("my_database");

返回参数

参数返回类型是否必选描述返回示例
namestring必选查询的数据库的名称。my_database
tenantstring可选所查询的数据库归属的租户。
当使用 seekdb 时,没有该参数。
sys
charsetstring可选所查询的数据库使用的字符集。utf8mb4
collationstring可选所查询的数据库使用的排序方式。utf8mb4_bin
metadatadict可选预留字段,暂无数据。{}

返回示例

Database {
name: 'my_database',
charset: 'utf8mb4',
collation: 'utf8mb4_bin',
metadata: {}
}

相关操作