Using MySQL Database
How to use a mysql database?
Explanation
Using MySQL Database
If you want to create tables for a database first you have to select the database. For selecting a database you have to enter the following query :
mysql> USE sample;
Database changed
Here
sample is the
database you want to select. The
USE command dosen't need a semicolon at the end of the query.
You can use the following command to view the current database that you're connected to:
Understand the difference between Use database and select database() as the former is selecting a database and the later one is displaying the currently selected one. After selecting the database you can create tables and other such operations.
Note :
You have to select a database in MySQL using the
USE command everytime you are entering into Mysql server or when you want to change the database.
If you type the following query you can see an information like
Empty set (ie.,) there are no tables in the selected database.
mysql> show tables;
Empty set (0.00 sec)