USE
Example
Section titled “Example”USE mydatabase;Output
Section titled “Output”There is no specific output for this command in MySQL as it silently switches to the specified database.
Explanation
Section titled “Explanation”The USE database_name; command switches the context to the specified database. In this case, it switches to ‘mydatabase’.
Example
Section titled “Example”USE AdventureWorks2012;SELECT * FROM Person.Address;Output
Section titled “Output”| AddressID | AddressLine1 | City | StateProvinceID | PostalCode ||-----------|----------------|------------|-----------------|------------|| 1 | 1970 Napa Ct. | Bothell | 79 | 98011 || 2 | 9833 Mt. Dias Bl. | Bothell | 79 | 98011 || ... | ... | ... | ... | ... |Explanation
Section titled “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.