Skip to main content
Log inGet a demo
Back to SQL Dictionary
Database functions

SQL Create Database

What is SQL CREATE DATABSE?

The SQL CREATE DATABASE statement is used to create a new database within a database management system (DBMS). A database is a structured collection of data organized and stored for efficient retrieval and management. Creating a new database is the first step in setting up an environment for data storage, organization, and retrieval.

When you would use it

You would use the SQL CREATE DATABASE statement when you want to:

  1. Set up a new database: Create a new, separate database for storing data distinct from other databases within the DBMS.

  2. Start a new project: When starting a new software project or application that requires data storage, you need to create a dedicated database for it.

  3. Implement a multi-tenant architecture: In scenarios where you need to create separate databases for different clients or tenants in a multi-tenant system.

  4. Restore a backup: When restoring a backup or migrating data to a new database.

Syntax

The syntax for creating a new database using the CREATE DATABASE statement varies among different database management systems (DBMS). Here is a generic template:

CREATE DATABASE database_name;
  • database_name: The name you want to give to the new database.

Parameter values

  • database_name: A user-defined name for the new database. It should be unique within the DBMS.

Example query

Here's an example of how to create a new database named "mydb" using the SQL CREATE DATABASE statement in SQL Server:

CREATE DATABASE mydb;

Example table response

The CREATE DATABASE statement doesn't produce a table response. It creates a new database, which is typically an empty structure initially. You can then create tables and add data to the database as needed.

Use cases

  • Setting up a new database for data storage.
  • Starting a new project that requires data management.
  • Implementing a multi-tenant architecture with separate databases for different clients.
  • Restoring a backup or migrating data to a new database.

SQL languages this is available for

The SQL CREATE DATABASE statement is available in various relational database management systems (RDBMS), including but not limited to:

  • SQL Server
  • MySQL
  • PostgreSQL
  • Oracle Database
  • IBM Db2
  • MariaDB
  • SQLite

The syntax and behavior may vary slightly depending on the specific DBMS, so it's essential to refer to the documentation for the DBMS you are using for precise details.

Related

SQL Stored Procedures

SQL Drop Database

SQL Backup Database

Share

Book a demo

Work email

Start syncing data in minutes

Check out this 5 minute interactive demo to learn how you can sync customer data to any business tool.

Hightouch Audiences user interface.

Activate your data in less than 5 minutes