SQL Create Database
How to CREATE DATABASE in SQL?
CREATE DATABASE statement used to create a new database.
It defines the basic structure and metadata for a database, allowing you to organize and store data.
Syntax:
Let's see the syntax how you can create a new databases in SQL.
CREATE DATABASE database_name;
database_name: The name you want to give to your new database.
Example:
Below is example of school database.
The name of database is 'school_database':
CREATE DATABASE school_database;
This example creates a new database named school_database.
Additional Options:
Specifying Character Set and Collation:
You can also specify the character set and collation for your database, which influences how data is stored and sorted.
CREATE DATABASE school_database
CHARACTER SET utf8
COLLATE utf8_general_ci;
In this example, the character set is set to UTF-8, and the collation is set to case-insensitive (utf8_general_ci).
Tips:
- Choose a meaningful and descriptive name for your database.
- Specify the character set and collation based on the requirements of your application.
After creating a database, you typically use the USE statement to start working within that database:
USE school_database;
This allows subsequent SQL statements to be executed within the context of the specified database.