Create a database - SQL Server (2024)

  • Article

Applies to: Create a database - SQL Server (1) SQL Server

This article describes how to create a database in SQL Server by using SQL Server Management Studio or Transact-SQL.

Note

To create a database in Azure SQL Database using T-SQL, see Create database in Azure SQL Database.

Limitations and restrictions

  • A maximum of 32,767 databases can be specified on an instance of SQL Server.

Prerequisites

  • The CREATE DATABASE statement must run in autocommit mode (the default transaction management mode) and isn't allowed in an explicit or implicit transaction.

Recommendations

  • The master database should be backed up whenever a user database is created, modified, or dropped.

  • When you create a database, make the data files as large as possible based on the maximum amount of data you expect in the database.

Permissions

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

To maintain control over disk use on an instance of SQL Server, permission to create databases is typically limited to a few SQL Server login.

Use SQL Server Management Studio

Create a database

  1. In Object Explorer, connect to an instance of the SQL Server Database Engine and then expand that instance.

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

  3. In New Database, enter a database name.

  4. To create the database by accepting all default values, select OK; otherwise, continue with the following optional steps.

  5. To change the owner name, select (...) to select another owner.

    Note

    The Use full-text indexing option is always checked and dimmed because, beginning in SQL Server 2008 (10.0.x), all user databases are full-text enabled.

  6. To change the default values of the primary data and transaction log files, in the Database files grid, select the appropriate cell and enter the new value. For more information, see Add Data or Log Files to a Database.

  7. To change the collation of the database, select the Options page, and then select a collation from the list.

  8. To change the recovery model, select the Options page and select a recovery model from the list.

  9. To change database options, select the Options page, and then modify the database options. For a description of each option, see ALTER DATABASE SET Options (Transact-SQL).

  10. To add a new filegroup, select the Filegroups page. Select Add and then enter the values for the filegroup.

  11. To add an extended property to the database, select the Extended Properties page.

    1. In the Name column, enter a name for the extended property.

    2. In the Value column, enter the extended property text. For example, enter one or more statements that describe the database.

  12. To create the database, select OK.

Use Transact-SQL

Create a database

  1. Connect to the Database Engine.

  2. From the Standard bar, select New Query.

  3. Copy and paste the following example into the query window and select Execute. This example creates the database Sales. Because the keyword PRIMARY isn't used, the first file (Sales_dat) becomes the primary file. Because MB or KB aren't specified in the SIZE parameter for the Sales_dat file, it uses MB and is allocated in megabytes. The Sales_log file is allocated in megabytes because the MB suffix is explicitly stated in the SIZE parameter.

USE master;GOCREATE DATABASE Sales ON(NAME = Sales_dat, FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL16.MSSQLSERVER\MSSQL\DATA\saledat.mdf', SIZE = 10, MAXSIZE = 50, FILEGROWTH = 5)LOG ON(NAME = Sales_log, FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL16.MSSQLSERVER\MSSQL\DATA\salelog.ldf', SIZE = 5 MB, MAXSIZE = 25 MB, FILEGROWTH = 5 MB);GO

For more examples, see CREATE DATABASE (SQL Server Transact-SQL).

Next steps

Create a database - SQL Server (2024)
Top Articles
¿Quién inventó el microscopio y en qué año?
➜ Google Activate | Respuestas EXAMEN FINAL PARTE 2 | Fundamentos de Marketing Digital
Camera instructions (NEW)
Ffxiv Shelfeye Reaver
12 Rue Gotlib 21St Arrondissem*nt
Alan Miller Jewelers Oregon Ohio
Boggle Brain Busters Bonus Answers
Hawkeye 2021 123Movies
Cumberland Maryland Craigslist
Samsung 9C8
Mawal Gameroom Download
Riegler & Partner Holding GmbH auf LinkedIn: Wie schätzen Sie die Entwicklung der Wohnraumschaffung und Bauwirtschaft…
Rubfinder
Erskine Plus Portal
Jvid Rina Sauce
7440 Dean Martin Dr Suite 204 Directions
Clarksburg Wv Craigslist Personals
Second Chance Maryland Lottery
Craigslist In Flagstaff
Daytonaskipthegames
Popular Chinese Restaurant in Rome Closing After 37 Years
Contracts for May 28, 2020
Baja Boats For Sale On Craigslist
Ac-15 Gungeon
Walgreens Bunce Rd
Sandals Travel Agent Login
Kroger Feed Login
Gen 50 Kjv
Speechwire Login
Pokémon Unbound Starters
What is Software Defined Networking (SDN)? - GeeksforGeeks
Stubhub Elton John Dodger Stadium
Ofw Pinoy Channel Su
Swgoh Boba Fett Counter
Have you seen this child? Caroline Victoria Teague
Ultra Clear Epoxy Instructions
Whas Golf Card
Ni Hao Kai Lan Rule 34
R&J Travel And Tours Calendar
Craigslist Lakeside Az
Lovein Funeral Obits
LumiSpa iO Activating Cleanser kaufen | 19% Rabatt | NuSkin
Makes A Successful Catch Maybe Crossword Clue
Ohio Road Construction Map
Graduation Requirements
303-615-0055
Ihop Deliver
Mmastreams.com
Naughty Natt Farting
Laurel Hubbard’s Olympic dream dies under the world’s gaze
Syrie Funeral Home Obituary
The Ultimate Guide To 5 Movierulz. Com: Exploring The World Of Online Movies
Latest Posts
Article information

Author: Maia Crooks Jr

Last Updated:

Views: 6709

Rating: 4.2 / 5 (63 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Maia Crooks Jr

Birthday: 1997-09-21

Address: 93119 Joseph Street, Peggyfurt, NC 11582

Phone: +2983088926881

Job: Principal Design Liaison

Hobby: Web surfing, Skiing, role-playing games, Sketching, Polo, Sewing, Genealogy

Introduction: My name is Maia Crooks Jr, I am a homely, joyous, shiny, successful, hilarious, thoughtful, joyous person who loves writing and wants to share my knowledge and understanding with you.