MySQL CREATE DATABASE Statement

MySQL CREATE DATABASE Statement – Complete Tutorial (Beginner → Interview Level)
The CREATE DATABASE statement in MySQL is used to create a new database where tables, views, procedures, and data are stored.
What is a Database in MySQL?
A database is an organized collection of:
Tables
Views
Indexes
Stored procedures
Data
Before creating tables, you must create a database first.
Basic Syntax of CREATE DATABASE
Simple Example
- Creates a database named college
Check Existing Databases
Use a Database (Very Important)
After creating a database, you must select it:
- All tables will now be created inside
college.
CREATE DATABASE IF NOT EXISTS
Prevents error if database already exists.
- Safe command (recommended in interviews & real projects)
CREATE DATABASE with Character Set
DROP DATABASE (Related Statement)
Deletes database permanently
- All tables and data will be lost
CREATE DATABASE vs CREATE SCHEMA
In MySQL:
DATABASEandSCHEMAare same
Common Errors & Solutions
| Error | Reason | Solution |
|---|---|---|
| Database exists | Duplicate name | Use IF NOT EXISTS |
| Access denied | Permission issue | Use admin/root |
| Can’t use database | Not selected | Use USE database_name |
Interview Questions & MCQs
Q1. Which command creates a database in MySQL?
A) MAKE DATABASE
B) ADD DATABASE
C) CREATE DATABASE
D) NEW DATABASE
Answer: C
Q2. Which command selects a database?
A) OPEN
B) SELECT
C) USE
D) CONNECT
Answer: C
Q3. What does IF NOT EXISTS do?
A) Deletes database
B) Prevents duplicate error
C) Renames database
D) Updates database
Answer: B
Q4. Which command shows all databases?
A) SHOW TABLES
B) SHOW DATABASES
C) LIST DATABASES
D) DISPLAY DATABASES
Answer: B
Q5. Is CREATE DATABASE reversible?
A) Yes
B) No
Answer: Yes (by DROP DATABASE, but data is lost)
Q6. DATABASE and SCHEMA in MySQL are:
A) Different
B) Same
C) Opposite
D) Unrelated
Answer: B
Real-Life Usage
- Create project database
- Create testing database
- Create application backend storage
- Multi-client database systems
Summary
CREATE DATABASEcreates a new databaseUse
USEto select itIF NOT EXISTSavoids errorsDATABASE = SCHEMA in MySQL
Foundational topic for SQL exams & interviews
