🎓 Top 15 Udemy Courses (80-90% Discount): My Udemy Courses - Ramesh Fadatare — All my Udemy courses are real-time and project oriented courses.
▶️ Subscribe to My YouTube Channel (178K+ subscribers): Java Guides on YouTube
▶️ For AI, ChatGPT, Web, Tech, and Generative AI, subscribe to another channel: Ramesh Fadatare on YouTube
Introduction
In this chapter, we will learn how to list all the databases available on your SQL server. This is useful for managing multiple databases and ensuring that the required databases are present. The SHOW DATABASES statement in SQL is used to display a list of all databases.
Listing Databases
The SHOW DATABASES statement is used to list all the databases on the SQL server.
Syntax
SHOW DATABASES;
Example
SHOW DATABASES;
This command will display a list of all databases available on the server.
Example Output
After executing the SHOW DATABASES statement, you might see an output like this:
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
| mydatabase |
| testdatabase |
+--------------------+
Explanation
information_schema: A system database that stores information about all other databases.mysql: A system database that contains information about users, privileges, and other administrative information.performance_schema: A system database used for performance monitoring.sys: A system database that provides simplified views for performance schema data.mydatabaseandtestdatabase: User-created databases.
Using SQL Workbench or Command Line
Using SQL Workbench
- Open SQL Workbench.
- Connect to Your SQL Server.
- Execute the Query:
- Enter the
SHOW DATABASES;statement in the query editor. - Click the execute button or press
Ctrl+Enter.
- Enter the
Using Command Line
- Open Command Line Interface (CLI) or terminal.
- Login to SQL Server:
mysql -u username -pEnter your password when prompted.
- Execute the Query:
SHOW DATABASES;
Filtering Databases
In some SQL systems, you can filter the list of databases using the LIKE clause.
Syntax
SHOW DATABASES LIKE 'pattern';
Example
SHOW DATABASES LIKE 'test%';
This command will display all databases whose names start with "test".
Conclusion
The SHOW DATABASES statement is a simple yet powerful command that helps you manage and organize your SQL databases. By listing all the databases on your server, you can easily keep track of your database environment and ensure that everything is in order.
My Top and Bestseller Udemy Courses. The sale is going on with a 70 - 80% discount. The discount coupon has been added to each course below:
Build REST APIs with Spring Boot 4, Spring Security 7, and JWT
[NEW] Learn Apache Maven with IntelliJ IDEA and Java 25
ChatGPT + Generative AI + Prompt Engineering for Beginners
Spring 7 and Spring Boot 4 for Beginners (Includes 8 Projects)
Available in Udemy for Business
Building Real-Time REST APIs with Spring Boot - Blog App
Available in Udemy for Business
Building Microservices with Spring Boot and Spring Cloud
Available in Udemy for Business
Java Full-Stack Developer Course with Spring Boot and React JS
Available in Udemy for Business
Build 5 Spring Boot Projects with Java: Line-by-Line Coding
Testing Spring Boot Application with JUnit and Mockito
Available in Udemy for Business
Spring Boot Thymeleaf Real-Time Web Application - Blog App
Available in Udemy for Business
Master Spring Data JPA with Hibernate
Available in Udemy for Business
Spring Boot + Apache Kafka Course - The Practical Guide
Available in Udemy for Business
Comments
Post a Comment
Leave Comment