In a real-world scenario, you will have multiple databases in your SQL Schema. In order to perform any kind of operations on the database, you need to select the database first.
The SQL USE statement is used to select any existing database in the SQL Schema.
SQL Select Database Syntax
The basic syntax of the SQL Select Database is as below.
USE database_name;
Database Name should be unique in the SQL Schema.
SQL Select Database Example
First, you check the available databases in the Schema using the following command.
mysql> SHOW DATABASES; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sakila | | sys | | testdb | | world | +--------------------+ 7 rows in set (0.00 sec)
Now, if you want to use world database, then you need to execute the following command first to select the database.
mysql> USE world; Database changed