How to create a database in MS SQL Server
Ways to create user databases on MS SQL Server.
Database includes objects such as tables, processes, functions . In MS SQL Server there are two types of databases
- System database
- User database
System database
The system database (database) is automatically created when you install MS SQL Server. Below is a list of system databases:
- Master
- Model MSDB
- Tempdb
- Resource (available from 2005 version)
- 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.
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.
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
- How to create users in MS SQL Server
- The CREATE USER command in SQL Server
- Database monitoring in MS SQL Server
- How to back up and restore a Microsoft SQL Server database using SSMS
- Microsoft Windows PowerShell and SQL Server 2005 SMO - Part 9
- Use the ALTER DATABASE command to migrate DATABASE in SQL Server
- Microsoft Windows PowerShell and SQL Server 2005 SMO - Part 10
- FUNCTION (Function) in SQL Server
- How to create a database in MySQL
- SQL Server setup is always available
- PROCEDURE (Procedure) in SQL Server
- What is MS SQL Server?
- Upload multiple XML files into XML data type columns
- How to decentralize users in MS SQL Server