1. CREATE DATABASE

Description

The CREATE DATABASE command is used to create a new database in the MySQL server. Each database name must be unique. If the database already exists, MySQL throws an error.

Syntax

CREATE DATABASE database_name;

Example

CREATE DATABASE mystudy;

2. CREATE DATABASE IF NOT EXISTS

Description

This command creates a database only if it does not already exist.
If the database exists, MySQL returns a warning instead of an error, making it safe for scripts.

Syntax

CREATE DATABASE IF NOT EXISTS database_name;

Example

CREATE DATABASE IF NOT EXISTS mystudy;

3. DROP DATABASE

Description

The DROP DATABASE command permanently deletes a database and all its contents, including tables and data.
This action cannot be undone.

Syntax

DROP DATABASE database_name;

Example

DROP DATABASE mystudy;

4. DROP DATABASE IF EXISTS

Description

Deletes the database only if it exists.
If the database does not exist, MySQL shows a warning instead of an error.

Syntax

DROP DATABASE IF EXISTS database_name;

Example

DROP DATABASE IF EXISTS mystudy;

5. USE DATABASE

Description

The USE command selects a database as the current working database.
All table operations will be performed inside this database.

Syntax

USE database_name;

Example

USE mystudy;

6. SHOW DATABASES

Description

Displays all databases available in the MySQL server.
Visibility depends on user privileges.

Syntax

SHOW DATABASES;

Example

SHOW DATABASES;