If you have multiple databases and you want to perform the operation in the database then firstly select database after that you can perform the operation.
Syntax:-
USE databaseName
Now, firstly check the all database through below command
SHOW DATABASES;
Output:-
+--------------------+
| Database |
+--------------------+
| information_schema |
| email_archive |
| flood |
| employee_system |
| performance_schema |
Now, you want to work in employee_system then use below command
Example:-
USE employee_system;
SQL Select Database – Interview Questions
Q 1: What does selecting a database mean?
Ans: It means setting the active database for executing SQL queries.
Q 2: Which command selects a database?
Ans: USE database_name;
Q 3: Is database selection mandatory?
Ans: Yes, before performing table operations, a database must be selected.
Q 4: Can we switch databases anytime?
Ans: Yes, the USE command allows switching databases.
Q 5: Does selecting a database modify data?
Ans: No, it only changes the active working database.
SQL Select Database – Objective Questions (MCQs)
Q1. Which command is used to select a database in SQL?
Q2. What does the USE database_name command do?
Q3. Which statement must be executed before creating tables?
Q4. Can multiple databases be used at the same time in one SQL session?
Q5. What happens if you use a non-existing database?