SQL Server Create Database

In this article, we will see SQL Server Create Database syntax and examples.

Definition:
SQL Server Database is made up of a collection of tables that stores a specific set of structured data. A table contains a collection of rows, also referred to as records or tuples, and columns, also referred to as attributes. Each column in the table is designed to store a certain type of information, for example, dates, names, dollar amounts, and numbers.

Every SQL Server database has two operating system files: a data file and a log file. Data files contain data and objects such as tables, indexes, stored procedures, and views. Log files contain the information that is required to recover all transactions in the database.

SQL Server Create Database Syntax:

CREATE DATABASE database_name [ CONTAINMENT = { NONE | PARTIAL } ] [ ON [ PRIMARY ] [ ,...n ] [ , [ ,...n ] ] [ LOG ON [ ,...n ] ] ] [ COLLATE collation_name ] [ WITH

Permissions:
Requires CREATE DATABASE permission in the master database, or requires CREATE ANY DATABASE, or ALTER ANY DATABASE permission.

SQL Server Create Database Examples

A. SQL Server Create Database using SQL Server Management Studio:

1. Connect to SQL Server instance.

2. Right-click Databases, and then click New Database.

SQL Server Create Database

3. In New Database, enter a database name.

4. To create the database by accepting all default values, click OK;

Or If you want provide optional values owner, files, filegroups then click on each of them and spcecify and click on ok.

B. SQL Server Create Database using SQL Statement:

CREATE DATABASE [r2schools] CONTAINMENT = NONE ON PRIMARY ( NAME = N'r2schools', FILENAME = N'E:\sql_data\r2schools.mdf' , SIZE = 8192KB , FILEGROWTH = 65536KB ) LOG ON ( NAME = N'r2schools_log', FILENAME = N'E:\sql_log\r2schools_log.ldf' , SIZE = 8192KB , FILEGROWTH = 65536KB )

So, in this article we have seen two different SQL Server Create Database examples and its syntax.