A Database in SQL Server consists of mainly database objects like Tables, Stored Procedures, User Defined Functions, Views and so on.
A database instance will usually be having multiple System Defined databases and User created databases.
MASTER,MSDB,MODEL and TEMPDB databases are the System Databases which shipped with SQL Server by default.
| SYSTEM DATABASE | DESCRIPTION |
| MASTER | Records all system-level information for an instance of SQL Server. |
| MSDB | Used by SQL Server Agent for scheduling alerts and jobs. |
| MODEL | Used as the template for all databases created on the instance of SQL Server. |
| TEMPDB | It is used for holding temporary objects or intermediate result-sets. |
Below is the Basic Syntax for Creating a Database in SQL Server.
Syntax:
CREATE DATABASE <databasename> ;
Example:
CREATE DATABASE sqltutorial;
Database names must be unique within an instance of SQL Server.
We can also create new database by using SQL Server Management Studio.
- Connect to SQL Server instance and right-click on the databases folder.
- Then click New Database
- Type the database name in the dialog box , for example, sqltutorial
- click OK.
We can use the USE statement to select the Database on which we want to perform the database operations.
USE <databasename>
DROP DATABASE
We can drop a database using DROP Statement
Syntax:
DROP DATABASE <databasename>;
Example:
DROP DATABASE sqltutorial ;
