getDatabase - 获取指定数据库
getDatabase() 用于获取指定数据库信息。
信息
仅支持在使用 SeekdbAdminClient 连接时,才能使用该接口。关于 SeekdbAdminClient 的详细介绍,参见 SeekdbAdminClient。
前提条件
-
您已经安装了 seekdb-js,有关安装 seekdb-js 的详细信息,参见 快速开始。
-
您已经安装了 seekdb 服务器模式,有关安装 seekdb 服务器模式的详细信息,参见 通过 yum install 部署 seekdb。
-
您已经连接到数据库。有关连接的详细操作参见 SeekdbAdminClient。
请求参数
getDatabase(name: string, tenant?: string)
| 参数 | 取值类型 | 是否必选 | 描述 | 取值示例 |
|---|---|---|---|---|
name | string | 必选 | 指定要查询的数据库的名称。 | my_database |
tenant | string | 可选
| 指定所创建的数据库归属的租户。 | 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");
返回参数
| 参数 | 返回类型 | 是否必选 | 描述 | 返回示例 |
|---|---|---|---|---|
name | string | 必选 | 查询的数据库的名称。 | my_database |
tenant | string | 可选 | 所查询的数据库归属的租户。 当使用 seekdb 时,没有该参数。 | sys |
charset | string | 可选 | 所查询的数据库使用的字符集。 | utf8mb4 |
collation | string | 可选 | 所查询的数据库使用的排序方式。 | utf8mb4_bin |
metadata | dict | 可选 | 预留字段,暂无数据。 | {} |
返回示例
Database {
name: 'my_database',
charset: 'utf8mb4',
collation: 'utf8mb4_bin',
metadata: {}
}