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
USE mydatabase;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
USE AdventureWorks2012;SELECT * FROM Person.Address;Output
| AddressID | AddressLine1 | City | StateProvinceID | PostalCode ||-----------|----------------|------------|-----------------|------------|| 1 | 1970 Napa Ct. | Bothell | 79 | 98011 || 2 | 9833 Mt. Dias Bl. | Bothell | 79 | 98011 || ... | ... | ... | ... | ... |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.