MySQL USE Database

A database instance will usually be having multiple System Defined databases and User created databases. We can use the USE statement to select the Database on which we want to perform the database operations. Basically USE statement changes the database context to the Specified Database. Below is the basic syntax of the USE statement.

Example:Let us execute the following statement to set the MySQL sample Database sakila as the current contextual database:

Now let us verify which the current contextual database by executing the following statement.


From the above result we can see that now the current contextual database is sakila, which is set by USE statement

Note: DATABASE() function shows the current contextual Database.

Leave a Reply

Your email address will not be published. Required fields are marked *