Home Tutorials SQL Tutorial Creating a Database
Creating a Database

Creating a Database


Creating a Database

Definition: The CREATE DATABASE statement is used to initialize a brand-new, empty database container within your database management system (DBMS).

Learning Outcome: Creating and managing databases is a fundamental skill. Before you can build tables or store information, you must first establish the root environment where all your data assets will live.


Syntax

The syntax is straightforward. You use the CREATE DATABASE keyword followed by the unique name you wish to give your new database.

CREATE DATABASE database_name;

Example

If you are building a system to manage a learning institution, you might run the following command:

CREATE DATABASE school;

Explanation

  • Execution: When this command is executed, the system reserves space and sets up the necessary background files for a database named school.
  • Naming Rules: Database names should be descriptive, unique, and typically do not contain spaces (use underscores like school_management instead).

Key Notes

  • Administrative Privileges: In many professional environments, you need specific "admin" or "create" permissions assigned to your user account to execute this command.
  • The Next Step: Once the database is created, you usually need to tell the system you want to work inside it by using the USE command (e.g., USE school;).
  • Case Sensitivity: While SQL keywords are not case-sensitive, some operating systems (like Linux) may treat the actual database name as case-sensitive. It is best practice to be consistent.

🏋️ Test Yourself With Exercises

Take our quiz on Creating a Database to test your knowledge.

Browse Quizzes »