MySQL: SHOW DATABASES Statement

Profile picture for user arilio666

To list all the databases in MySQL and view them to select a particular needed one out of it we can use the following statement. It is called the show databases statement.

Syntax

SHOW DATABASES;
  • So with this show databases, we can couple it with % and LIKE clause to get the most of it like for example let's say we have a huge DB or DB with similar names.
  • In that case, we can use this LIKE clause and % sign to get the specific queried DB out of it.

Example

1. List All DBs

show databases;

This will list all the present databases on a local server.

2. List DBs Whose Name Ends With 'Tory'

show databases like '%tory';

  • So here we have coupled the statement with LIKE and % as we discussed and got the name of a DB ending with the words 'tory'.
  • % in the front means get ending with letters.
  • % in the back means get starting with letters.
Tags