SHOW

The SHOW keyword provides database and table information.

SHOW DATABASES

Show all databases:

  1. SHOW [FULL] DATABASES;
  1. +---------+
  2. | Schemas |
  3. +---------+
  4. | public |
  5. +---------+
  6. 1 row in set (0.01 sec)

Show databases by LIKE pattern:

  1. SHOW DATABASES LIKE 'p%';

Show databases by where expr:

  1. SHOW DATABASES WHERE Schemas='test_public_schema';

Show all databases with options:

  1. create database with(ttl='7d');
  2. SHOW FULL DATABASES;
  1. +--------------------+-------------+
  2. | Database | Options |
  3. +--------------------+-------------+
  4. | greptime_private | |
  5. | information_schema | |
  6. | public | |
  7. | test | ttl='7days' |
  8. +--------------------+-------------+

SHOW TABLES

Show all tables:

  1. SHOW TABLES;
  1. +---------+
  2. | Tables |
  3. +---------+
  4. | numbers |
  5. | scripts |
  6. +---------+
  7. 2 rows in set (0.00 sec)

Show tables in the test database:

  1. SHOW TABLES FROM test;

Show tables by like pattern:

  1. SHOW TABLES like '%prometheus%';

Show tables by where expr:

  1. SHOW TABLES FROM test WHERE Tables='numbers';

SHOW FULL TABLES

  1. SHOW FULL TABLES [IN | FROM] [DATABASE] [LIKE pattern] [WHERE query]

It will list all tables and table types in the database:

  1. SHOW FULL TABLES;
  1. +---------+------------+
  2. | Tables | Table_type |
  3. +---------+------------+
  4. | monitor | BASE TABLE |
  5. | numbers | TEMPORARY |
  6. +---------+------------+
  7. 2 rows in set (0.00 sec)
  • Tables: the table names.
  • Table_type: the table types, such as BASE_TABLE, TEMPORARY, and VIEW etc.

It supports like and where query too:

  1. SHOW FULL TABLES FROM public like '%mo%';
  1. +---------+------------+
  2. | Tables | Table_type |
  3. +---------+------------+
  4. | monitor | BASE TABLE |
  5. +---------+------------+
  6. 1 row in set (0.01 sec)
  1. SHOW FULL TABLES WHERE Table_type='BASE TABLE';
  1. +---------+------------+
  2. | Tables | Table_type |
  3. +---------+------------+
  4. | monitor | BASE TABLE |
  5. +---------+------------+
  6. 1 row in set (0.01 sec)

SHOW CREATE TABLE

Shows the CREATE TABLE statement that creates the named table:

  1. SHOW CREATE TABLE [table]

For example:

  1. SHOW CREATE TABLE system_metrics;
  1. +----------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  2. | Table | Create Table |
  3. +----------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  4. | system_metrics | CREATE TABLE IF NOT EXISTS `system_metrics` (
  5. `host` STRING NULL,
  6. `idc` STRING NULL,
  7. `cpu_util` DOUBLE NULL,
  8. `memory_util` DOUBLE NULL,
  9. `disk_util` DOUBLE NULL,
  10. `ts` TIMESTAMP(3) NOT NULL DEFAULT current_timestamp(),
  11. TIME INDEX (`ts`),
  12. PRIMARY KEY (`host`, `idc`)
  13. )
  14. ENGINE=mito
  15. WITH(
  16. regions = 1
  17. ) |
  18. +----------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  • Table: the table name.
  • Create Table: The SQL to create the table.

SHOW CREATE FLOW

Shows the CREATE FLOW statement that creates the flow task.

For example:

  1. public=> SHOW CREATE FLOW filter_numbers;
  1. Flow | Create Flow
  2. ----------------+-------------------------------------------------------
  3. filter_numbers | CREATE OR REPLACE FLOW IF NOT EXISTS filter_numbers +
  4. | SINK TO out_num_cnt +
  5. | AS SELECT number FROM numbers_input WHERE number > 10
  6. (1 row)

SHOW FLOWS

Show all flows:

  1. public=> SHOW FLOWS;
  1. Flows
  2. ----------------
  3. filter_numbers
  4. (1 row)

also support LIKE expression:

  1. public=> show flows like "filter%";
  1. Flows
  2. ----------------
  3. filter_numbers
  4. (1 row)

SHOW CREATE VIEW

To show the view’s definition:

  1. SHOW CREATE VIEW cpu_monitor;
  1. +-------------+--------------------------------------------------------------+
  2. | View | Create View |
  3. +-------------+--------------------------------------------------------------+
  4. | cpu_monitor | CREATE VIEW cpu_monitor AS SELECT cpu, host, ts FROM monitor |
  5. +-------------+--------------------------------------------------------------+

SHOW VIEWS

List all views:

  1. SHOW VIEWS;
  1. +----------------+
  2. | Views |
  3. +----------------+
  4. | cpu_monitor |
  5. | memory_monitor |
  6. +----------------+

Of course, it supports LIKE:

  1. SHOW VIEWS LIKE 'cpu%';
  1. +-------------+
  2. | Views |
  3. +-------------+
  4. | cpu_monitor |
  5. +-------------+

And where:

  1. SHOW VIEWS WHERE Views = 'memory_monitor';
  1. +----------------+
  2. | Views |
  3. +----------------+
  4. | memory_monitor |
  5. +----------------+

Extensions to SHOW Statements

Some extensions to SHOW statements accompany the implementation of INFORMATION_SCHEMA just like MySQL, they also accept a WHERE clause that provides more flexibility in specifying which rows to display.

GreptimeDB supports some extensions for MySQL compatibility, it’s good for tools like Navicat for MySQL or dbeaver to connect GreptimeDB.

  1. SHOW CHARACTER SET;

Output just like the INFORMATION_SCHEMA.CHARACTER_SETS table:

  1. +---------+---------------+-------------------+--------+
  2. | Charset | Description | Default collation | Maxlen |
  3. +---------+---------------+-------------------+--------+
  4. | utf8 | UTF-8 Unicode | utf8_bin | 4 |
  5. +---------+---------------+-------------------+--------+

SHOW COLLATION for INFORMATION_SCHEMA.COLLATIONS table.

  1. SHOW INDEX FROM monitor;

To list all indexes in a table:

  1. +---------+------------+------------+--------------+-------------+-----------+-------------+----------+--------+------+----------------------------+---------+---------------+---------+------------+
  2. | Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | Visible | Expression |
  3. +---------+------------+------------+--------------+-------------+-----------+-------------+----------+--------+------+----------------------------+---------+---------------+---------+------------+
  4. | monitor | 1 | PRIMARY | 1 | host | A | NULL | NULL | NULL | YES | greptime-inverted-index-v1 | | | YES | NULL |
  5. | monitor | 1 | TIME INDEX | 1 | ts | A | NULL | NULL | NULL | NO | greptime-inverted-index-v1 | | | YES | NULL |
  6. +---------+------------+------------+--------------+-------------+-----------+-------------+----------+--------+------+----------------------------+---------+---------------+---------+------------+

Which is the extension of INFORMATION_SCHEMA.TABLE_CONSTRAINTS.

List all the columns in a table:

  1. SHOW COLUMNS FROM monitor;

Output just like INFORMATION_SCHEMA.COLUMNS:

  1. +--------+--------------+------+------------+---------------------+-------+----------------------+
  2. | Field | Type | Null | Key | Default | Extra | Greptime_type |
  3. +--------+--------------+------+------------+---------------------+-------+----------------------+
  4. | cpu | double | Yes | | 0 | | Float64 |
  5. | host | string | Yes | PRI | NULL | | String |
  6. | memory | double | Yes | | NULL | | Float64 |
  7. | ts | timestamp(3) | No | TIME INDEX | current_timestamp() | | TimestampMillisecond |
  8. +--------+--------------+------+------------+---------------------+-------+----------------------+

All these SHOW extensions accept WHERE:

  1. SHOW COLUMNS FROM monitor WHERE Field = 'cpu';
  1. +-------+--------+------+------+---------+-------+---------------+
  2. | Field | Type | Null | Key | Default | Extra | Greptime_type |
  3. +-------+--------+------+------+---------+-------+---------------+
  4. | cpu | double | Yes | | 0 | | Float64 |
  5. +-------+--------+------+------+---------+-------+---------------+

Other SHOW statements:

  • SHOW STATUS and SHOW VARIABLES are not supported, just return empty results.
  • SHOW TABLE STATUS is the extension of INFORMATION_SCHEMA.TABLES.