SHOW Statements
N.B. SHOW CREATE (TABLE|DATABASE|USER)
hides secrets unless
display_secrets_in_show_and_select
server setting
is turned on,
format_display_secrets_in_show_and_select
format setting
is turned on and user has
displaySecretsInShowAndSelect
privilege.
SHOW CREATE TABLE | DICTIONARY | VIEW | DATABASE
SHOW [CREATE] [TEMPORARY] TABLE|DICTIONARY|VIEW|DATABASE [db.]table|view [INTO OUTFILE filename] [FORMAT format]
Returns a single column of type String containing the CREATE query used for creating the specified object.
SHOW TABLE t
and SHOW DATABASE db
have the same meaning as SHOW CREATE TABLE|DATABASE t|db
, but SHOW t
and SHOW db
are not supported.
Note that if you use this statement to get CREATE
query of system tables, you will get a fake query, which only declares table structure, but cannot be used to create table.
SHOW DATABASES
Prints a list of all databases.
SHOW DATABASES [[NOT] LIKE | ILIKE '<pattern>'] [LIMIT <N>] [INTO OUTFILE filename] [FORMAT format]
This statement is identical to the query:
SELECT name FROM system.databases [WHERE name [NOT] LIKE | ILIKE '<pattern>'] [LIMIT <N>] [INTO OUTFILE filename] [FORMAT format]
Examples
Getting database names, containing the symbols sequence 'de' in their names:
SHOW DATABASES LIKE '%de%'
Result:
┌─name────┐
│ default │
└─────────┘
Getting database names, containing symbols sequence 'de' in their names, in the case insensitive manner:
SHOW DATABASES ILIKE '%DE%'
Result:
┌─name────┐
│ default │
└─────────┘
Getting database names, not containing the symbols sequence 'de' in their names:
SHOW DATABASES NOT LIKE '%de%'
Result:
┌─name───────────────────────────┐
│ _temporary_and_external_tables │
│ system │
│ test │
│ tutorial │
└────────────────────────────────┘
Getting the first two rows from database names:
SHOW DATABASES LIMIT 2
Result:
┌─name───────────────────────────┐
│ _temporary_and_external_tables │