How to create a database in MS SQL Server

Database includes objects such as tables, processes, functions . In MS SQL Server there are two types of databases

  1. System database
  2. User database

System database

The system database (database) is automatically created when you install MS SQL Server. Below is a list of system databases:

  1. Master
  2. Model MSDB
  3. Tempdb
  4. Resource (available from 2005 version)
  5. Distribution (only for Relication feature)

User database

User databases are created by users themselves (administrators, developers, testers . who have access to create databases). Here are the ways to create user databases.

Method 1 : Create a database using T-SQL Script or Restore Database

This is the basic syntax for creating databases in MS SQL Server:

Create database 

Or

Restore Database from disk = '

For example:

To create a database named Testdb, run the following query:

Create database Testdb

Or:

Restore database Testdb from disk = 'D:BackupTestdb_full_backup.bak'

Note that D: backup is where the backup file is saved and Testdb_full_backup.bak is the name of the backup file.

Method 2 : Create database using SQL Server Management Studio

Connect to the SQL Server installation and right-click the database folder. Click to create a new database and the screen below will appear.

How to create a database in MS SQL Server Picture 1
The screen fills in the information for the newly created database

Enter the name of the CSLD (as in the example above is Testdb) and click OK. The Testdb database will be created as shown below.

How to create a database in MS SQL Server Picture 2
Testdb database has been created

Previous article: Ways to log in database on MS SQL Server

Next lesson: How to select the database in MS SQL Server

4 ★ | 1 Vote

May be interested

  • PROCEDURE (Procedure) in SQL ServerPROCEDURE (Procedure) in SQL Server
    procedure is a program in the database that contains many statements that you save for later use but have different points from function. the article will give you the syntax and examples of how to create and delete procedures in sql server.
  • SQL Server setup is always availableSQL Server setup is always available
    database mirroring solution helps build a high-availability database management system in sql server which is quite simple and suitable for medium-sized and lower-level databases.
  • What is MS SQL Server?What is MS SQL Server?
    this article will give you a general introduction to sql server, demonstrating the benefits and benefits of using sql server as well as existing versions.
  • How to decentralize users in MS SQL ServerHow to decentralize users in MS SQL Server
    administrators can create, delete or deny permissions in ms sql server. the permissions here refer to database access (csdl). you can create, delete or deny permissions in ms sql server.
  • Upload multiple XML files into XML data type columnsUpload multiple XML files into XML data type columns
    sql server database administrators often have some needs such as importing multiple files into a table in the database. this article will discuss how to upload multiple files (especially xml files) into the xml data column of the sql server database.
  • Network basics: Part 3 - DNS ServerNetwork basics: Part 3 - DNS Server
    a dns server is a server that contains a database of public ip addresses and hostnames associated with them. in most cases, the dns server is used to resolve or translate those common names into ip addresses as required.
  • How to Set Up a Microsoft SQL Server Database in Docker on LinuxHow to Set Up a Microsoft SQL Server Database in Docker on Linux
    traditionally, sql server databases were set up on dedicated servers or virtual machines, but docker has changed all that.
  • Learn about the role concept in SQL ServerLearn about the role concept in SQL Server
    in any database management system, security and security are always top priority. and with sql server, if we take advantage of the many advantages of this application, those who manage the system administration will greatly reduce the burden as well as the pressure on the job.
  • Ways to log in database on MS SQL ServerWays to log in database on MS SQL Server
    below are instructions on how to log into the database on ms sql server.
  • Create VPN Server on Windows 8Create VPN Server on Windows 8
    no need to install any additional applications, you can easily 'turn' your computer into a vpn server if you're using windows 8. in this way, you can share data from the computer. as a simple lan system in the form of remote access. & a