Database

Setting up MS SQL database.

Introduction

Now that you have your SQL server set up done, The first step towards efficiently storing and managing data using SQL is to create a SQL database. We'll go step-by-step through the process of creating a SQL database, making tables, and inserting data in this section.

Database

create database

A database is a container that holds your tables and other database objects such as views, indexes, and stored procedures. To create a new database, use the CREATE DATABASE command. This command initializes a new database with the specified name

Create database

Syntax

  CREATE DATABASE DB_name;                                 

Example

  CREATE DATABASE CustomerManagementSystem;                                 

This command creates the database with name 'CustomerManagementSystem', and you can then begin creating tables within it.

Delete database

If you want to delete an already created database, use the DROP DATABASE command.

Syntax

  DROP DATABASE DB_name;                                 

Example

  DROP DATABASE CustomerManagementSystem;                               

The USE command in SQL is used to select a specific database in your SQL server to work with.

Syntax

  USE DB_name;                                 

Example

   USE CustomerManagementSystem;                               

After executing this command, all subsequent SQL queries will be executed on the 'CustomerManagementSystem' database unless another database is specified.

Conclusion

To create a new database, use the CREATE DATABASE command; to delete a database completely, use the DROP DATABASE command; and to switch to a specific database, use the USE command.