SQL CREATE DATABASE


SQL CREATE DATABASE Statement

The SQL CREATE DATABASE statement is used to create a new database. This command sets up a new database environment where you can create tables and store data, providing a structured and organized space for managing information.


Syntax

CREATE DATABASE database_name;
  • CREATE DATABASE: This is the SQL keyword used to create a new database.
  • database_name: This specifies the name of the database you want to create.

Example

Let's go through a complete example that includes creating a new database and then using it to create a table.

Step 1: Creating a Database

This step involves creating a new database named example_db.

CREATE DATABASE example_db;

In this example, we create a database named example_db.

Step 2: Using the New Database

This step involves selecting the newly created database to use it for subsequent operations.

USE example_db;

This command selects example_db as the current database.