How To Create A Database In MySQL

Tutorial on how to create database in MySQL for beginners.

MySQL Create Database Tutorial

MySQL is a programming language which acts as an interface between the user and the database. This tutorial helps you to create an Oracle Database using the MySQL code. MySQL commands have to be entered through a command prompt and there is no graphical visual interface. Follow the below steps in the tutorial on how to create a database in MySQL.
How To Create Database Mysql
Syntax for creating a Database:
How To Create Database Mysql Syntax
Follow the below steps to create the database called as "Employees".
Step 1: Display all available databases:
In the MySQL command prompt, enter the command SHOW DATABASES;
It lists all the databases you have stored.
Show Database Before Creating Database
Step 2: Create the Database:

From the MySQL command line, enter the command CREATE DATABASE Employees;
Database Name cannot include spaces.
Semicolon ";" is a must at the end of the MySQL command.
Create Database
Step 3: Display the databases again:
Now you could see the database "Employees" in the list.
Show Database After Creating Database
Step 4: Select your database to edit it:
Enter the command USE Employees;
You can see the message "Database changed".
Now your active database is Employees.
Use Database
Step 5: Create a table in the database Employees:
A database can contain one or more tables.
CREATE TABLE Employee_Details (emp_id INT, Name CHAR(25), Sex CHAR(10), Age INT(9));.
This will create a table named "Employee_Details" with three fields: emp_id, Name and Age.
Create Table
The INT command will make the emp_id field contain only numbers (integers).
The CHAR (characters) command will make the name field contain only characters.
The number next to the commands indicates how many characters or integers can fit in the field.
Step 6: Enter values in the table.
INSERT INTO Employee_Details (emp_id, Name, Sex, Age) VALUES (2345, Abella, F, 34);
Insert Values Into Table
Step 7: You can enter more rows in the table.
You can create multiple entries using a single command.
INSERT INTO Employee_Details (emp_id, Name, Sex, Age) VALUES (2346, Santa, F, 47), (2347, Grader, M, 26), (2348, Ritula, F, 32);
Insert Multiple Rows Into Table
Step 8: Retrieve data from your Database.
Use SELECT statement to query values from tables in your database.
SELECT * FROM Employee_Details;
This will return all the rows in your table as "*" means "all".
Retrieve Values From Table
Step 9: Drop your Database.
Below is the MySQL statement to drop a database.
This will completely drop (delete) the database "Employees" with all its tables.
Drop Database