MYSQL - select database?

MySQLMySQLi 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”.

Updated on 30-Jul-2019 22:30:24