DATABASE

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
MASTERRecords all system-level information for an instance of SQL Server.
MSDBUsed by SQL Server Agent for scheduling alerts and jobs.
MODELUsed as the template for all databases created on the instance of SQL Server.
TEMPDBIt 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 ;

Leave a comment

Design a site like this with WordPress.com
Get started