文档文档

InfluxQL SHOW 语句

使用 InfluxQL SHOW 语句从数据库查询架构信息。

SHOW RETENTION POLICIES

使用 SHOW RETENTION POLICIES 语句列出与数据库关联的保留策略。每个数据库都有一个保留策略——autogen

在 InfluxDB 3 Core 中,保留策略不是数据结构的一部分,但 InfluxQL 需要它们,并在 FROM 子句中的完全限定测量中使用。为每个保留策略返回的数据并不代表数据库的实际保留相关属性。这些值是占位符值,仅用于 InfluxQL 功能的兼容性。

有关数据库数据保留的信息,请参阅 列出数据库

SHOW RETENTION POLICIES [ON <database-name>]

示例

-- Show retention policies in the database specified in the query request
SHOW RETENTION POLICIES

-- Show retention policies in a specific database
SHOW RETENTION POLICIES ON "example-database"

SHOW MEASUREMENTS

使用 SHOW MEASUREMENTS 语句列出数据库中的测量。

SHOW MEASUREMENTS [with_measurement_clause] [where_clause] [limit_clause] [offset_clause]

示例

-- Show all measurements
SHOW MEASUREMENTS

-- Show measurements where region tag = 'uswest' AND host tag = 'serverA'
SHOW MEASUREMENTS WHERE "region" = 'uswest' AND "host" = 'serverA'

-- Show measurements that start with 'h2o'
SHOW MEASUREMENTS WITH MEASUREMENT =~ /h2o.*/

SHOW FIELD KEYS

使用 SHOW FIELD KEYS 语句列出测量中的所有字段键。

SHOW FIELD KEYS [from_clause]

示例

-- Show field keys and field value data types from all measurements
SHOW FIELD KEYS

-- Show field keys and field value data types from specified measurement
SHOW FIELD KEYS FROM "cpu"

SHOW TAG KEYS

使用 SHOW TAG KEYS 语句列出测量中的标签键。

SHOW TAG KEYS [from_clause] [where_clause] [limit_clause] [offset_clause]

示例

-- Show all tag keys
SHOW TAG KEYS

-- Show all tag keys from the cpu measurement
SHOW TAG KEYS FROM "cpu"

-- Show all tag keys from the cpu measurement where the region key = 'uswest'
SHOW TAG KEYS FROM "cpu" WHERE "region" = 'uswest'

-- Show all tag keys where the host key = 'serverA'
SHOW TAG KEYS WHERE "host" = 'serverA'

SHOW TAG VALUES

使用 SHOW TAG VALUES 语句列出数据库中指定标签的值。

SHOW TAG VALUES [from_clause] WITH KEY = <tag-expression> [where_clause] [limit_clause] [offset_clause]

默认情况下,SHOW TAG VALUES 语句仅返回 **最近一天** 的唯一标签值。要修改时间范围,请包含一个 带有基于时间谓词的 WHERE 子句

包含 FROM 子句

强烈建议在 SHOW TAG VALUES 语句中包含一个 FROM 子句,该子句指定要查询的 1-50 个表。如果没有 FROM 子句,InfluxDB 查询引擎必须读取所有表中的数据,并返回每个表中的唯一标签值。

根据数据库中的表数量以及每个表中的唯一标签值数量,省略 FROM 子句可能导致查询性能不佳、查询超时或不必要的资源分配,从而影响其他查询。

示例

-- Show tag values from the cpu measurement for the region tag
SHOW TAG VALUES FROM "cpu" WITH KEY = "region"

-- Show tag values from the cpu measurement for the region tag for a custom time range
SHOW TAG VALUES FROM "cpu" WITH KEY = "region" WHERE time > -7d

-- Show tag values from multiple measurements for the region tag
SHOW TAG VALUES FROM "cpu", "memory", "disk" WITH KEY = "region"

-- Show tag values from the cpu measurement for all tag keys that do not include the letter c
SHOW TAG VALUES FROM "cpu" WITH KEY !~ /.*c.*/

-- Show tag values from the cpu measurement for region & host tag keys where service = 'redis'
SHOW TAG VALUES FROM "cpu" WITH KEY IN ("region", "host") WHERE "service" = 'redis'

此页面是否有帮助?

感谢您的反馈!


InfluxDB 3.8 新特性

InfluxDB 3.8 和 InfluxDB 3 Explorer 1.6 的主要增强功能。

查看博客文章

InfluxDB 3.8 现已适用于 Core 和 Enterprise 版本,同时发布了 InfluxDB 3 Explorer UI 的 1.6 版本。本次发布着重于操作成熟度,以及如何更轻松地部署、管理和可靠地运行 InfluxDB。

更多信息,请查看

InfluxDB Docker 的 latest 标签将指向 InfluxDB 3 Core

在 **2026 年 2 月 3 日**,InfluxDB Docker 镜像的 latest 标签将指向 InfluxDB 3 Core。为避免意外升级,请在您的 Docker 部署中使用特定的版本标签。

如果使用 Docker 来安装和运行 InfluxDB,latest 标签将指向 InfluxDB 3 Core。为避免意外升级,请在您的 Docker 部署中使用特定的版本标签。例如,如果使用 Docker 运行 InfluxDB v2,请将 latest 版本标签替换为 Docker pull 命令中的特定版本标签 — 例如

docker pull influxdb:2