InfluxQL SHOW 语句
使用 InfluxQL SHOW
语句从数据库查询模式信息。
SHOW RETENTION POLICIES
使用 SHOW RETENTION POLICIES
语句列出与数据库关联的保留策略。每个数据库都有一个保留策略–autogen
。
在 InfluxDB 集群版中,保留策略不是数据结构的一部分,但 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 集群版和本文档的反馈和错误报告。要获得支持,请使用以下资源
拥有年度合同或支持合同的客户可以联系 InfluxData 支持。