Back to SQL Notes
Topic #72

CREATE DATABASE in SQL

The CREATE DATABASE statement creates a new, empty database — a container you'll then fill with tables.

Syntax

CREATE DATABASE database_name;

Example

CREATE DATABASE coding_now_academy;

To start using it in most tools:

USE coding_now_academy;

To see what already exists:

SHOW DATABASES;   -- MySQL
\l                -- PostgreSQL (psql shortcut)

Avoiding Errors on Re-Run

CREATE DATABASE IF NOT EXISTS coding_now_academy;

Without IF NOT EXISTS, re-running the statement on a database that already exists throws an error. This matters in setup scripts you might run more than once.

Dialect Note

PostgreSQL doesn't support IF NOT EXISTS for CREATE DATABASE the same way MySQL does — you typically check with SELECT 1 FROM pg_database WHERE datname = '...' first, or just handle the error in your script. SQL Server uses the same core CREATE DATABASE database_name; syntax as MySQL.

Common Mistakes

  • Confusing a database name with a table name when writing USE vs FROM
  • Creating a new database for every small project instead of using separate schemas/tables inside one — usually unnecessary overhead

Interview Relevance

Rarely tested in isolation, but interviewers expect you to know it's the first real step before CREATE TABLE — some candidates jump straight to tables and get asked "where does this table live?"

Practice Question

Write a statement that creates a database called library_system only if it doesn't already exist.

Want to go beyond the notes?

Join Coding Now Tech Institute's SQL course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

CREATE DATABASE in SQL – FAQs

Quick answers about learning CREATE DATABASE in SQL in SQL.

This free note from Coding Now Tech Institute explains CREATE DATABASE in SQL in SQL — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every SQL topic on Coding Now Tech Institute, including CREATE DATABASE in SQL, is 100% free with no signup required.
With focused practice, most students grasp CREATE DATABASE in SQL in 1–3 days from these notes; pairing it with Coding Now Tech Institute's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the Coding Now Tech Institute Community (/community) — expert instructors answer within 24 hours.
Call NowEnroll Now