SQL Create DB

CREATE DATABASE creates a new database. Learn how to create, list, and manage databases safely.

On this page

SQL CREATE DATABASE

The CREATE DATABASE statement is used to create a new database.

Basic Syntax

CREATE DATABASE database_name;

Example

CREATE DATABASE company_db;

This creates a new database named company_db.

Avoid Errors if Database Exists

Some database systems support IF NOT EXISTS to prevent errors.

CREATE DATABASE IF NOT EXISTS company_db;

Select a Database

After creating a database, you must select it before creating tables.

USE company_db;

List Databases (MySQL / MariaDB)

SHOW DATABASES;

Important Notes

  • You need proper privileges to create a database
  • Database names should be meaningful and lowercase (recommended)
  • Character set and collation can be specified during creation

Create Database with Charset

CREATE DATABASE company_db
CHARACTER SET utf8mb4
COLLATE utf8mb4_unicode_ci;

Common Mistakes

  • Forgetting to select the database with USE
  • Creating databases without defining character sets
  • Using reserved keywords as database names

Next Step

Continue with SQL Drop DB to learn how to remove a database safely.