8.2 KiB
Use InfluxQL SHOW
statements to return information about your data schema.
{{% influxql/v1-v3-data-model-note %}}
- List measurements in a database
- List field keys in a measurement
- List tag keys in a measurement
- List tag values for a specific tag key
[!Note]
Sample data
The following examples use data provided in sample data sets. To run the example queries and return identical results, follow the instructions provided for each sample data set to write the data to your {{% product-name %}} database.
List measurements in a database
Use SHOW MEASUREMENTS
to list measurements in your InfluxDB database.
SHOW MEASUREMENTS
{{< expand-wrapper >}} {{% expand "View example output" %}}
{{% influxql/table-meta %}} name: measurements {{% /influxql/table-meta %}}
name |
---|
bitcoin |
home |
home_actions |
numbers |
weather |
{{% /expand %}} {{< /expand-wrapper >}}
List measurements that contain specific tag key-value pairs
To return only measurements with specific tag key-value pairs, include a WHERE
clause with tag key-value pairs to query for.
SHOW MEASUREMENTS WHERE room = 'Kitchen'
{{< expand-wrapper >}} {{% expand "View example output" "1" %}}
{{% influxql/table-meta %}} name: measurements {{% /influxql/table-meta %}}
name |
---|
home |
home_actions |
{{% /expand %}} {{< /expand-wrapper >}}
List measurements that match a regular expression
To return only measurements with names that match a
regular expression,
include a WITH
clause that compares the MEASUREMENT
to a regular expression.
SHOW MEASUREMENTS WITH MEASUREMENT =~ /^home/
{{< expand-wrapper >}} {{% expand "View example output" "2" %}}
{{% influxql/table-meta %}} name: measurements {{% /influxql/table-meta %}}
name |
---|
home |
home_actions |
{{% /expand %}} {{< /expand-wrapper >}}
List field keys in a measurement
Use SHOW FIELD KEYS
to return all field keys in a measurement.
Include a FROM
clause to specify the measurement.
If no measurement is specified, the query returns all field keys in the database.
SHOW FIELD KEYS FROM home
{{< expand-wrapper >}} {{% expand "View example output" "3" %}}
{{% influxql/table-meta %}} name: home {{% /influxql/table-meta %}}
fieldKey | fieldType |
---|---|
co | integer |
hum | float |
temp | float |
{{% /expand %}} {{< /expand-wrapper >}}
List tag keys in a measurement
Use SHOW TAG KEYS
to return all tag keys in a measurement.
Include a FROM
clause to specify the measurement.
If no measurement is specified, the query returns all tag keys in the database.
SHOW TAG KEYS FROM home_actions
{{< expand-wrapper >}} {{% expand "View example output" "4" %}}
{{% influxql/table-meta %}} name: home_actions {{% /influxql/table-meta %}}
tagKey |
---|
action |
level |
room |
{{% /expand %}} {{< /expand-wrapper >}}
List tag keys in measurements that contain a specific tag key-value pair
To return all tag keys measurements that contain specific tag key-value pairs,
include a WHERE
clause with the tag key-value pairs to query for.
SHOW TAG KEYS WHERE room = 'Kitchen'
{{< expand-wrapper >}} {{% expand "View example output" "5" %}}
{{% influxql/table-meta %}} name: home {{% /influxql/table-meta %}}
tagKey |
---|
room |
{{% influxql/table-meta %}} name: home_actions {{% /influxql/table-meta %}}
tagKey |
---|
action |
level |
room |
{{% /expand %}} {{< /expand-wrapper >}}
List tag values for a specific tag key
Use SHOW TAG VALUES
to return all values for specific tags in a measurement.
- Include a
FROM
clause to specify one or more measurements to query. - Use the
WITH
clause to compareKEY
to tag keys to list the values of. - Use the
WHERE
clause to restrict the search to a specific time range (default time range is the last day).
SHOW TAG VALUES FROM weather WITH KEY = location
[!Note]
Include a FROM clause
We strongly recommend including a
FROM
clause with theSHOW TAG VALUES
statement that specifies 1-50 tables to query. Without aFROM
clause, the InfluxDB query engine must read data from all tables and return unique tag values from each.Depending on the number of tables in your database and the number of unique tag values in each table, excluding a
FROM
clause can result in poor query performance, query timeouts, or unnecessary resource allocation that may affect other queries.
{{< expand-wrapper >}} {{% expand "View example output" "5" %}}
{{% influxql/table-meta %}} name: weather {{% /influxql/table-meta %}}
key | value |
---|---|
location | Concord |
location | Hayward |
location | San Francisco |
{{% /expand %}} {{< /expand-wrapper >}}
List tag values for multiple tags
To return tag values for multiple specific tag keys, use the IN
operator in
the WITH
clause to compare KEY
to a list of tag keys.
SHOW TAG VALUES FROM home_actions WITH KEY IN ("level", "action")
{{< expand-wrapper >}} {{% expand "View example output" "6" %}}
{{% influxql/table-meta %}} name: home_actions {{% /influxql/table-meta %}}
key | value |
---|---|
action | alert |
action | cool |
level | ok |
level | warn |
{{% /expand %}} {{< /expand-wrapper >}}
List tag values for tags that match a regular expression
To return only tag values from tags keys that match a regular expression, use
regular expression comparison operators in your WITH
clause to compare KEY
to the regular expression.
SHOW TAG VALUES FROM home, home_actions WITH KEY =~ /oo/
{{< expand-wrapper >}} {{% expand "View example output" "7" %}}
{{% influxql/table-meta %}} name: home {{% /influxql/table-meta %}}
key | value |
---|---|
room | Kitchen |
room | Living Room |
{{% influxql/table-meta %}} name: home_actions {{% /influxql/table-meta %}}
key | value |
---|---|
room | Kitchen |
room | Living Room |
{{% /expand %}} {{< /expand-wrapper >}}
List tag values associated with a specific tag key-value pair
To list tag values for tags associated with a specific tag key-value pair:
- Use the
WITH
clause to identify what tag keys to return values for. - Include a
WHERE
clause that identifies the tag key-value pair to query for.
The following example returns tag values for the action
and level
tags for
points where the room
tag value is Kitchen
.
SHOW TAG VALUES FROM home_actions WITH KEY IN ("action", "level") WHERE room = 'Kitchen'
{{< expand-wrapper >}} {{% expand "View example output" "8" %}}
{{% influxql/table-meta %}} name: home_actions {{% /influxql/table-meta %}}
key | value |
---|---|
action | alert |
action | cool |
level | ok |
level | warn |
{{% /expand %}} {{< /expand-wrapper >}}