MySQL CREATE DATABASE Statement

MySQL Tutorial

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

  •  Useful for multilingual data (Hindi, emojis, etc.)

 DROP DATABASE (Related Statement)

Deletes database permanently

  •  All tables and data will be lost

 CREATE DATABASE vs CREATE SCHEMA

In MySQL:

  • DATABASE and SCHEMA are same

 Common Errors & Solutions

ErrorReasonSolution
Database existsDuplicate nameUse IF NOT EXISTS
Access deniedPermission issueUse admin/root
Can’t use databaseNot selectedUse 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 DATABASE creates a new database

  • Use USE to select it

  • IF NOT EXISTS avoids errors

  • DATABASE = SCHEMA in MySQL

  • Foundational topic for SQL exams & interviews

You may also like...