Home » SQL » SQL Create Database Command

SQL Create Database Command

Introduction: CREATE DATABASE command

SQL CREATE DATABASE command in SQL server use to creates a new database. In this Tutorial you will learn the Syntax of CREATE DATABASE statement and few example to explained in detail.

Need of Database in SQL?

Any Organization data stored in Database as in the form of many Tables. These tables are specified the one pattern of onformation Like Customers information can be stored in “Customer Info” Database in different tables , Like: Customers_Details, Orders_Details, Shipping_Details, Sales_details etc, These tables contains the informations of Customers.

Syntax: CREATE DATABASE

CREATE DATABASE database_name;

above syntax specify the keyword Create database and databse_name, which is the name of database where all tables will be stored.

Example #1: Create Test_database using SQL Command

In below example we are creating test_database using SQL CREATE DATABASE command

CREATE DATABASE Test_database;

Once this database will get created , it will start reflecting in your SQL server management Studio in Database folder in left side for panel. you can se in below result Screenshot.

After command you can go to left panel in SQL Management Studio and right click on database and then Refresh.

Result:

create database

You will see the Database

create database2

Example #2: Create database from SSMS panel – manually

You can also create database from SQL server management Studio left explore panel manually. This is the second option to create database in SQL server.

Step 1: Open SSMS from your local machine

Step 2: login with your credential

Step 3: . Right click on Database option and click on New Database

create database1

Step 4: . Enter Database name and click on Finish you will get “successful creation database” message

create database

Example #3: Show all databases in the SQL Server

Sometime you need to look for how many numbers of database is available in SQL server, fo that you can use below command to list down all Database lists available in SQL server.

SELECT 

      name 

FROM 

      master.sys.databases 

ORDER BY 

      name;