Class 12 | MySQL

Execute simple SQL commands using the MySQL

MySQL prompt:
mysql>
this is the prompt of MySQL, and we have to issue a command at this prompt

MySQL Show/List Databases

command: show databases
This command helps us to display all the databases present in the MySQL server.

mysql> SHOW DATABASES;

MySQL Create Database

Command: create database
This command helps us to create a database.

Syntax:
create database database_name;

MySQL SELECT Database

SELECT Database is used in MySQL to select a particular database to work with. This query is used when multiple databases are available with MySQL Server.

You can use SQL command “USE” to select a particular database.

syntax:
USE database_name;

MySQL DROP Database

We can drop/delete/remove a MySQL database quickly with the MySQL DROP DATABASE command. It will delete the database along with all the tables, indexes, and constraints permanently. Therefore, we should have to be very careful while removing the database in MySQL because we will lose all the data available in the database. If the database is not available in the MySQL server, the DROP DATABASE statement throws an error.

syntax:
DROP DATABASE database_name;