- SQL Basics
- SQL Introduction
- SQL Syntax
- SQL Sample Database
- SQL SELECT
- SQL WHERE
- SQL ORDER BY
- SQL DISTINCT
- SQL LIMIT
- SQL FETCH
- SQL AND
- SQL OR
- SQL BETWEEN
- SQL IN
- SQL LIKE
- SQL IS NULL
- SQL Comparison Operators
- SQL Logical Operators
- SQL Alias
- SQL CASE
- Joins and Subqueries
- SQL INNER JOIN
- SQL LEFT JOIN
- SQL RIGHT JOIN
- SQL FULL OUTER JOIN
- SQL SELF JOIN
- SQL CROSS JOIN
- SQL Subquery
- SQL Correlated Subquery
- SQL UNION
- SQL INTERSECT
- SQL EXCEPT
- Aggregate Functions
- SQL AVG
- SQL COUNT
- SQL MAX
- SQL MIN
- SQL SUM
- SQL GROUP BY
- SQL HAVING
- SQL ROLLUP
- SQL CUBE
- SQL GROUPING SETS
- Database Management
- SQL CREATE DATABASE
- SQL ALTER DATABASE
- SQL DROP DATABASE
- SQL BACKUP DATABASE
- SQL SHOW DATABASES
- SQL SELECT DATABASE
- Table Management
- SQL CREATE TABLE
- SQL ALTER TABLE
- SQL ADD COLUMN
- SQL DROP COLUMN
- SQL DROP TABLE
- SQL TRUNCATE TABLE
- SQL SHOW TABLES
- SQL RENAME TABLE
- SQL Constraints
- SQL Primary Key
- SQL Foreign Key
- SQL UNIQUE Constraint
- SQL CHECK Constraint
- SQL NOT NULL Constraint
SQL SHOW DATABASES
The SHOW DATABASES
statement is used to list all available databases in a database management system (DBMS).
Key Features of SQL SHOW DATABASES
- Displays a list of all databases in the system.
- Requires appropriate privileges to view databases.
- Works in MySQL, MariaDB, and some other database systems.
SQL SHOW DATABASES Syntax
SHOW DATABASES;
Output Example:
This lists all databases on the server.
Using LIKE
to Filter Databases
To filter databases by name pattern:
SHOW DATABASES LIKE 'test%';
Output:
Database Name |
---|
test_db |
This shows only databases that start with "test".
Checking Databases in SQL Server
In SQL Server, use the following command instead:
SELECT name FROM sys.databases;
Summary
SHOW DATABASES
lists all databases in MySQL/MariaDB.- Use
LIKE
to filter specific databases. - For SQL Server, use
sys.databases
.