USE
USE is a statement in SQL that is used to select a particular database in an RDBMS. It allows you to specify the database on which subsequent SQL commands will be executed.
Example
Output
There is no specific output for this command in MySQL as it silently switches to the specified database.
Explanation
The USE database_name;
command switches the context to the specified database. In this case, it switches to ‘mydatabase’.
Example
Output
Explanation
In this example, USE AdventureWorks2012;
is setting the context to the AdventureWorks2012
database. SELECT * FROM Person.Address;
query then fetches all records from the Address
table in the Person
schema within this database. The result is a table displaying all the columns and rows in the Address
table.