Database is a collection of objects such as table, view, stored procedure, function, trigger, etc.
In MS SQL Server, two types of databases are available.
System databases are created automatically when we install MS SQL Server. Following is a list of system databases −
User databases are created by users (Administrators, developers, and testers who have access to create databases).
Following methods are used to create user database.
Following is the basic syntax for creating database in MS SQL Server.
Create database <yourdatabasename>
Restore Database <Your database name> from disk = '<Backup file location + file name>
To create database called ‘Testdb’, run the following query.
Create database Testdb
Restore database Testdb from disk = 'D:\Backup\Testdb_full_backup.bak'
Note − D:\backup is location of backup file and Testdb_full_backup.bak is the backup file name
Connect to SQL Server instance and right-click on the databases folder. Click on new database and the following screen will appear.
Enter the database name field with your database name (example: to create database with the name ‘Testdb’) and click OK. Testdb database will be created as shown in the following snapshot.