SQL reference (MySQL and MariaDB dialects)

SHOW statements

Every SHOW statement the Raft DB parser accepts, what it returns here, and the SHOW statements that are refused.

SHOW statements list databases, tables, columns, indexes, definitions, variables and other metadata. GUI tools and drivers use them to fill their object browsers.

Syntax#

SQL
SHOW { DATABASES | SCHEMAS } [LIKE 'pattern']
SHOW [FULL] TABLES [{ FROM | IN } db_name] [LIKE 'pattern' | WHERE expr]
SHOW [FULL] { COLUMNS | FIELDS } { FROM | IN } tbl_name [{ FROM | IN } db_name]
    [LIKE 'pattern' | WHERE expr]
SHOW { INDEX | INDEXES | KEYS } { FROM | IN } tbl_name [{ FROM | IN } db_name]
SHOW CREATE TABLE tbl_name
SHOW CREATE VIEW view_name
SHOW CREATE SEQUENCE seq_name
SHOW CREATE { DATABASE | SCHEMA } [IF NOT EXISTS] db_name
SHOW CREATE { PROCEDURE | FUNCTION } routine_name
SHOW CREATE TRIGGER trigger_name
SHOW GRANTS [FOR account]
SHOW [GLOBAL | SESSION] VARIABLES [LIKE 'pattern']
SHOW [GLOBAL | SESSION] STATUS [LIKE 'pattern']
SHOW WARNINGS
SHOW ERRORS
SHOW ENGINES
SHOW { CHARACTER SET | CHARSET } [LIKE 'pattern' | WHERE expr]
SHOW COLLATION [LIKE 'pattern' | WHERE expr]
SHOW TABLE STATUS [{ FROM | IN } db_name] [LIKE 'pattern' | WHERE expr]
SHOW { PROCEDURE | FUNCTION } STATUS [{ FROM | IN } db_name] [LIKE 'pattern' | WHERE expr]
SHOW TRIGGERS [{ FROM | IN } db_name] [LIKE 'pattern' | WHERE expr]
SHOW EVENTS [{ FROM | IN } db_name] [LIKE 'pattern' | WHERE expr]
SHOW OPEN TABLES [{ FROM | IN } db_name] [LIKE 'pattern' | WHERE expr]
SHOW PLUGINS [LIKE 'pattern' | WHERE expr]
SHOW PROCESSLIST

GLOBAL and SESSION after SHOW are accepted on any form.

Arguments#

NameMeaningDefault
FULLSHOW FULL TABLES adds Table_type (BASE TABLE, VIEW, SEQUENCE); SHOW FULL COLUMNS adds collation, privileges and comment columns.off
LIKE 'pattern'Filter by name (% and _). The column header shows the pattern, e.g. Tables_in_db (r%), Database (p).none
WHERE exprFilter on the columns of the answer by their names (Field, Type, Table_type, Db, ...).none

Remarks#

  • What is real. SHOW DATABASES, TABLES, COLUMNS, INDEX, CREATE TABLE/VIEW/SEQUENCE/DATABASE/PROCEDURE/FUNCTION/TRIGGER, GRANTS, TABLE STATUS, PROCEDURE STATUS, FUNCTION STATUS, TRIGGERS, CHARACTER SET, COLLATION, WARNINGS and ERRORS describe what exists. SHOW CHARACTER SET and SHOW COLLATION give the real lists of each server (41 and 286 rows for MySQL 9.7; 40 and 550 for MariaDB 11.4).
  • What is a fixed or empty answer. SHOW ENGINES has one row (InnoDB, DEFAULT, "Raft DB stores every table; there is one engine"). SHOW STATUS has three fixed rows (Uptime, Threads_connected, Questions). SHOW EVENTS and SHOW OPEN TABLES are empty (there are no events). SHOW PLUGINS lists the two password plugins. SHOW PROCESSLIST shows the current connection only. SHOW TABLE STATUS gives Rows 0 and the other sizes 0 (the engine reports no estimates).
  • SHOW VARIABLES lists the session's variables of the dialect (513 for MySQL 9.7, 554 for MariaDB 11.4). See system variables.
  • SHOW CREATE TABLE prints what the chosen dialect's server prints, with the generated, invisible, check and foreign-key parts; AUTO_INCREMENT=n is shown. Unique indexes are listed before the others. The character-set introducer printed for string literals in checks is _utf8mb4.
  • SHOW CREATE VIEW prints the stored text, not MySQL's canonical text.
  • SHOW INDEX: Cardinality is 0 (MySQL's value is an estimate); Visible shows invisible indexes; a functional index shows Column_name NULL and the expression in Expression.
  • Differences between the dialects. SHOW PROCEDURE STATUS has a Language column in MySQL only. MariaDB lists databases in one alphabetical order; MySQL lists information_schema first. SHOW COLLATION has no Pad_attribute column in MariaDB. SHOW TABLES lists sequences with type SEQUENCE.
  • A temporary table is not listed by SHOW TABLES but is shown by SHOW COLUMNS, SHOW CREATE TABLE and SHOW INDEX.
  • Privileges. SHOW DATABASES, SHOW TABLES, DESCRIBE and information_schema show only what the account may see. SHOW CREATE TABLE needs some privilege on the table (denial text uses SHOW). SHOW GRANTS FOR another account needs the privileges MySQL asks for.

Not supported yet#

SHOW PRIVILEGES and SHOW CREATE USER account are answered as the servers answer them. A server without a binary log and without replicas is what Raft DB looks like: SHOW BINARY LOGS is error 1381 (MariaDB also SHOW MASTER LOGS); SHOW BINLOG EVENTS, SHOW MASTER STATUS / SHOW BINARY LOG STATUS, SHOW REPLICAS / SHOW SLAVE HOSTS, SHOW REPLICA STATUS / SHOW SLAVE STATUS and SHOW PROFILES / SHOW PROFILE are empty, and the spelling the dialect does not have (MySQL 9 has no MASTER or SLAVE; MariaDB no REPLICAS) is a syntax error as in MySQL.

Every other SHOW is refused with error 1235 ("this SHOW statement"), among them: SHOW ENGINE ... STATUS, SHOW CREATE EVENT, SHOW COUNT(*) WARNINGS, SHOW RELAYLOG EVENTS, SHOW PARSE_TREE, SHOW STATUS with the server's own counters.

Examples#

Example:

SQL
SHOW TABLES;
SHOW FULL TABLES FROM db12 WHERE table_type = 'BASE TABLE';
SHOW TRIGGERS FROM db12;
SHOW PROCEDURE STATUS WHERE db = 'db12';
SHOW CREATE DATABASE db12;
SHOW FULL COLUMNS FROM t;
SHOW CREATE TABLE t;
SHOW COLLATION LIKE 'utf8mb4_general%';
SHOW VARIABLES LIKE 'character_set_server';
SHOW DATABASES LIKE 'p';        -- header: Database (p)
SHOW TABLES LIKE 'r%';

See also#