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 Core 和本文档提供反馈和错误报告。要获得支持,请使用以下资源
具有年度合同或支持合同的客户可以 联系 InfluxData 支持。