Computer >> Computer tutorials >  >> Programming >> MySQL

MYSQL - select database?


Whenever you get MySQL - selected database, that means you need to select database. The USE command is what you should focus on in this case. The syntax is as follows −

USE yourDatabaseName;

The example of USE database is as follows. Suppose, I am creating a table and I haven’t selected any database before, then in this type of situation, select database, else an error will arise. Here is the demo.

mysql> create table Demoofselectdatabase
   -> (
   -> Id int
   -> );
ERROR 1046 (3D000): No database selected

Then you can work with the ‘USE’ command. The query is as follows −

mysql> use business;
Database changed

Now, you are in a situation to create tables in the database “business”.