• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
sqlserver tutorial

SQL Server Tutorial

SQL Server Tutorial for Beginners

  • HOME
  • START HERE
  • BASICS
  • ADVANCED
    • Index
    • Views
    • Triggers
    • Stored Procedures
    • User-defined Functions
  • FUNCTIONS
Home / SQL Server Basics / SQL Server CREATE DATABASE

SQL Server CREATE DATABASE

Learning Objective

The objective of this tutorial is to teach you how to create a new database in SQL server using CREATE DATABASE statement or SQL Server Management Studio.

Introduction to CREATE DATABASE in SQL Server

The CREATE DATABASE statement is used to create a new database in SQL Server. You can create a database in SQL Server in two methods.

  1. Using T-SQL i.e. using CREATE DATABASE statement
  2. Using SQL Server Management Studio

Creating a new database in SQL Server using CREATE DATABASE statement

You can create new database by issuing CREATE DATABASE statement.

SQL Server CREATE DATABASE Syntax

The following is the syntax of SQL Server CREATE DATABASE statement.

CREATE DATABASE databasename;

In this syntax,

  • CREATE DATABASE – Keyword to create new database in SQL Server.
  • databasename – Name of the new database, you want to create in SQL Server.

Please note that you need to specify the databasename unique within the SQL Server instance.

SQL Server CREATE DATABASE Example

The below statement creates a new database named sampleDB.

CREATE DATABASE sampleDB;

Once the statement is completed successfully, you can check the name of the database using the below query which lists all the database name the SQL Server instance.

SELECT
   name
FROM
   sys.databases
ORDER BY
   name;

or you can execute one store procedure named sp_databases;

EXEC sp_databases;

Alternatively, you can check in the object explorer by reloading the object list by clicking the Refresh button or by pressing F5 in the keyboard.

SQL Server CREATE DATABASE

Creating a New Database Using SQL Server Management Studio

If you are more comfortable with the GUI, you can easily create a new database in SQL Server using SQL Server Management Studio.

First right-click on the Databases folder and click on New Database option as below.

SQL Server Create Database using SQL Server Management Studio

Now provide the name of the New database and click the OK button. In our case, we are giving TestDB as the new database name.

Finally, you can verify the name of the newly created database in the object explorer.

Summary

In this tutorial, you have learned how to create a new database in SQL Server using the CREATE DATABASE statement and SQL Server Management Studio.

Was this tutorial helpful?
YesNo
« Previous: SQL Server CUBE
SQL Server DROP DATABASE :Next »

Primary Sidebar

DATA MANIPULATION

  • SELECT
  • SELECT TOP
  • SELECT DISTINCT
  • OFFSET FETCH
  • ORDER BY
  • GROUP BY
  • BETWEEN
  • LIKE
  • ALIAS
  • HAVING
  • AND
  • OR
  • IN
  • WHERE
  • SELECT INTO
  • INSERT
  • INSERT Multiple rows
  • INSERT INTO SELECT
  • UPDATE
  • DELETE
  • PRIMARY KEY
  • FOREIGN KEY
  • UNIQUE CONSTRAINT
  • NOT NULL CONSTRAINT
  • SUBQUERY
  • CORRELATED SUBQUERY
  • JOINS
  • CROSS JOIN
  • INNER JOIN
  • LEFT JOIN
  • RIGHT JOIN
  • FULL JOIN
  • SELF JOIN
  • UPDATE Join
  • CASE
  • COALESCE
  • NULL
  • NULLIF
  • UNION
  • INTERSECT
  • MERGE
  • EXCEPT
  • EXISTS
  • GROUPING SET
  • PIVOT
  • ROLLUP
  • CUBE

DATA DEFINITION

  • CREATE DATABASE
  • DROP DATABASE
  • CREATE SCHEMA
  • ALTER SCHEMA
  • DROP SCHEMA
  • CREATE TABLE
  • RENAME TABLE
  • DROP TABLE
  • TRUNCATE TABLE
  • IDENTITY column
  • Sequence
  • ALTER TABLE ADD Column
  • ALTER TABLE ALTER Column
  • ALTER TABLE DROP Column

Footer

About

SQLServerTutorial.org provides free tutorials and guide on SQL Server for Developers, Database Administrators, and Solution Architects who want to get started SQL Server quickly.

Recent Posts

  • SQL Server DROP VIEW
  • SQL Server Indexed View
  • Check view definition
  • SQL Server Rename View
  • SQL Server List Views

Quick Links

  • About
  • Contact Us
  • Privacy Policy
  • SQL Server Index
  • SQL Server Views
  • Terms of Use

Copyright © 2023 www.sqlservertutorial.org. All Rights Reserved.