SHOW

The SHOW keyword provides database and table information.

SHOW DATABASES

Show all databases:

sql

  1. SHOW DATABASES;

sql

  1. +---------+
  2. | Schemas |
  3. +---------+
  4. | public |
  5. +---------+
  6. 1 row in set (0.01 sec)

Show databases by LIKE pattern:

sql

  1. SHOW DATABASES LIKE 'p%';

Show databases by where expr:

sql

  1. SHOW DATABASES WHERE Schemas='test_public_schema';

SHOW TABLES

Show all tables:

sql

  1. SHOW TABLES;

sql

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

Show tables in the test database:

sql

  1. SHOW TABLES FROM test;

Show tables by like pattern:

sql

  1. SHOW TABLES like '%prometheus%';

Show tables by where expr:

sql

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

SHOW CREATE TABLE

Shows the CREATE TABLE statement that creates the named table:

sql

  1. SHOW CREATE TABLE [table]

For example:

sql

  1. SHOW CREATE TABLE system_metrics;

sql

  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. +----------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+