MySQL USE DB

MySQL USE Database Statement


The USE statement in MySQL is used to select and switch to a specific database, making it the active database for subsequent queries.


Syntax:


USE database_name;


  • database_name is the name of the database you want to use.

Example: Switching to a Database


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.


Checking the Selected Database


To verify the active database:


SELECT DATABASE();



Listing Available Databases


To see all databases in MySQL:


SHOW DATABASES;






All Database statements:


✔ 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.



Whereisstuff is simple learing platform for beginer to advance level to improve there skills in technologies.we will provide all material free of cost.you can write a code in runkit workspace and we provide some extrac features also, you agree to have read and accepted our terms of use, cookie and privacy policy.
© Copyright 2024 www.whereisstuff.com. All rights reserved. Developed by whereisstuff Tech.