MySQL Tutorial
The USE statement in MySQL is used to select and switch to a specific database, making it the active database for subsequent queries.
USE database_name;
database_name is the name of the database you want to use.Switch to the school_db database
USE school_db;
After executing this command, all queries will run within school_db unless another database is selected.
To verify the active database:
SELECT DATABASE();
To see all databases in MySQL:
SHOW DATABASES;
✔ The USE statement sets the active database.
✔ All queries after USE database_name; apply to the selected database.
✔ Use SHOW DATABASES; to list available databases.
✔ Use SELECT DATABASE(); to check the current database.