rnew icon6Grab Deal : Flat 20% off on live classes + 2 free self-paced courses! - SCHEDULE CALL rnew icon7

All You Need To Know About Creating An Sql Database

 

A database is an organized collection of structured information, or data, typically stored electronically in a computer system. A database management system (DBMS) typically controls a database. Any kind of data can be stored, updated, and accessed through databases. They gather data about people, places, and things. That information is gathered in one place to be observed and analyzed. Databases are an organized collection of information.We will learn the various syntaxes for creating an SQL database and how to access it in the following paragraphs. We will also discuss SQL Server create database microsoft sql server and MySQL Create database syntax.

What is SQL Database

The most widely used programming language for extracting and organizing relational database data is SQL. A database is a table that consists of rows and columns. SQL is the language of databases. It facilitates retrieving specific information from databases that are further used for analysis.Over the next few paragraphs, we will learn about different ways of creating an SQL database and how to access it. Data is an integral part of businesses, and there’s great demand for administrators. Therefore go through the SQL DBA career path if you too want to set yourself up for this role. We will also learn about the different syntaxes to create an SQL Server database and learn how to call a database. 

Use of SQL Database

The Primary Applications of Databases are as Follows:

  • Improve Business Processes: Organizations gather information about business processes like sales, order processing, and customer service. They analyze that data to enhance these procedures, expand their business, and increase revenue.
  • Keep Track of Customers: Databases often store information about people, such as customers or users. Social media platforms, for instance, store user data like names, email addresses, and user behavior in databases. The data provides users with content recommendations and enhances the user experience.
  • Secure Personal Health Information: Healthcare providers use databases to securely store personal health data to inform and improve patient care.
  • Store Personal Data: Personal data can also be stored in databases. For instance, individual users can store media, like photos, in a managed cloud with personal cloud storage.

Different Ways to Create an SQL Database

There are mainly three ways to create an SQL Database

  • Through SQL Server Management Studio 
  • Through SQL Query 
  • Through Command Prompt 
Create a Database Through SQL Server Management Studio

The screenshot for the SQL Server Management Studio looks like below.

 

Following are the steps to create a database using SQL Server Management Studio

1) Log in to SQL Server Management Studio.  

2) Following Screen Appears

 

3) Select Database and Right-Click on it.

4) The Following Screen Appears.  

5) Provide The Name of The Database and Click ok 

6) Database is Created as Below

 

This is how you create a normal database in SQL Server. If you want to add some additional features to the database you can do so by following

Follow Till Step 5 and Go to Options

  • To change the owner name, click (…) to pick another owner.
  • To change the default values of the first data and transaction log files within the Database files grid, click the editable cell and enter the new value.
  • To change the collation of the database, select the Options page and then select a collation from the list.
  • To change the recovery model, select the Options page, and choose a recovery model from the list.

To add more filegroups, click the Filegroups option. Click Add, and then enter the values for the filegroup.

 

Create a Database Through SQL Query

The syntax for creating a database using transacts SQL is as follows.

Create Database Databasename

[ ON
[ PRIMARY ]  [...n ]
[,  [...n ] ]
[ LOG ON  [...n ] ]
]
[ COLLATE collation_name ]
[ WITH

Following are the steps by step how to create a database using transact SQL.

1) Log in to SQL Server Management Studio.  

2) Click on The New Query Button.

3) The Screen Looks Like Below

4) If You Want to Create a Simple Database, The Syntax is as Below

Create Database Testdatabase for Blog 

and click on execute

5) If The Syntax is ok, Then The Database is Created With The Following Message  

6) The Database is Created as Below.

 

If you want to add some additional features to your database through transacting SQL following is the syntax to do it.

Create DataBase Test Database For Blog  

ON (NAME = testdatabaseforblog_dat, --logical datafile name
    FILENAME = 'D:\DATA\ testdatabaseforblog. mdf',  --physical datafile name
    SIZE = 10,  MAXSIZE = 50,  FILEGROWTH = 5)  
LOG ON  (NAME = testdatabaseforblog_log, --logical logfile name
         FILENAME = 'D:\DATA\ testdatabaseforblog log. ldf',  --physical logfile name
         SIZE = 5MB,  MAXSIZE = 25MB,  FILEGROWTH = 5MB );  
GO
Create a Database Through Command Prompt

There is a third way how you can create a database. This is through the command prompt. Below is how you evoke the command prompt.

1) Type CMD in The Windows Search Bar to Invoke The Command Prompt.

 

2) Following Screen Appears

3) Type sqlcmd against the command prompt and press enter. The command prompt changes to 1>

Now let us understand step by step how to create a database using the command prompt. The syntax for creating a database using a command prompt is as follows.

Create Database Database Name

[ ON
     [ PRIMARY ]  [...n ]
     [,  [...n ] ]
     [ LOG ON  [...n ] ]
]
[ COLLATE collation_name ]
[ WITH

For creating an authoritative database using the command prompt following is the syntax

create database testdatabaseforblog made the database will be created.

If you want to add some addition, al features to your database you can use the following syntax

Create Database Test Database for Blog  

ON (NAME = testdatabaseforblog_dat, --logical datafile name
FILENAME = 'D:\DATA\ testdatabaseforblog. mdf',  --physical datafile name
SIZE = 10,  MAXSIZE = 50,  FILEGROWTH = 5)  
LOG ON  (NAME = testdatabaseforblog_log, --logical logfile name
FILENAME = 'D:\DATA\ testdatabaseforblog log. ldf',  --physical logfile name
SIZE = 5MB,  MAXSIZE = 25MB,  FILEGROWTH = 5MB );  
GO

The Screenshot Looks Like Below

How to Use SQL Database

We have learned to create SQL database using three different techniques. Next, we will learn how to use the database.

Using SQL Server Management Studio

Once you have created a database, you just need to select the database name from the top to activate the database.

Using Transact SQL Command

From transact SQL, you need to use the following SQL query to activate your database.

Use [testdatabaseforblog]
go.
Using Command Prompt
use [testdatabaseforblog]
go.

Following is The Screenshot.

How to Delete MySQL Database 

We have learned how to create a database and also how to use a database. Finally, we will learn how to delete a database.

Through SQL Server Management Studio

Right click on the database that needs to be deleted and click on delete. The database will be deleted.

1) Log on to SQL Server Management Studio

2) Select a database other than the database to be deleted.

3) On the query window, type in the following command.

Through Transact SQL
  1. Drop database [testdatabaseforblog]
  2.  The database will be deleted.

Through Command Prompt

Go to SQL command prompt from the Dos window.

Type the following command

drop database [testdatabaseforblog]
go.
The database will be deleted.

Conclusion

Over the last few paragraphs, we learned about databases and their use. We have also known different ways to create a database in SQL Server. We have learned how to use a database and delete an existing database if it is no longer in user. I hope this will give a fair bit of idea to the readers about the basics of SQL server database creation, or to learn more you can enroll to online sql server training.

cta14 icon

SQL Testing Training

  • Personalized Free Consultation
  • Access to Our Learning Management System
  • Access to Our Course Curriculum
  • Be a Part of Our Free Demo Class

Trending Courses

Cyber Security icon

Cyber Security

  • Introduction to cybersecurity
  • Cryptography and Secure Communication 
  • Cloud Computing Architectural Framework
  • Security Architectures and Models
Cyber Security icon1

Upcoming Class

-1 day 19 Apr 2024

QA icon

QA

  • Introduction and Software Testing
  • Software Test Life Cycle
  • Automation Testing and API Testing
  • Selenium framework development using Testing
QA icon1

Upcoming Class

-1 day 19 Apr 2024

Salesforce icon

Salesforce

  • Salesforce Configuration Introduction
  • Security & Automation Process
  • Sales & Service Cloud
  • Apex Programming, SOQL & SOSL
Salesforce icon1

Upcoming Class

7 days 27 Apr 2024

Business Analyst icon

Business Analyst

  • BA & Stakeholders Overview
  • BPMN, Requirement Elicitation
  • BA Tools & Design Documents
  • Enterprise Analysis, Agile & Scrum
Business Analyst icon1

Upcoming Class

-1 day 19 Apr 2024

MS SQL Server icon

MS SQL Server

  • Introduction & Database Query
  • Programming, Indexes & System Functions
  • SSIS Package Development Procedures
  • SSRS Report Design
MS SQL Server icon1

Upcoming Class

-1 day 19 Apr 2024

Data Science icon

Data Science

  • Data Science Introduction
  • Hadoop and Spark Overview
  • Python & Intro to R Programming
  • Machine Learning
Data Science icon1

Upcoming Class

6 days 26 Apr 2024

DevOps icon

DevOps

  • Intro to DevOps
  • GIT and Maven
  • Jenkins & Ansible
  • Docker and Cloud Computing
DevOps icon1

Upcoming Class

5 days 25 Apr 2024

Hadoop icon

Hadoop

  • Architecture, HDFS & MapReduce
  • Unix Shell & Apache Pig Installation
  • HIVE Installation & User-Defined Functions
  • SQOOP & Hbase Installation
Hadoop icon1

Upcoming Class

0 day 20 Apr 2024

Python icon

Python

  • Features of Python
  • Python Editors and IDEs
  • Data types and Variables
  • Python File Operation
Python icon1

Upcoming Class

-1 day 19 Apr 2024

Artificial Intelligence icon

Artificial Intelligence

  • Components of AI
  • Categories of Machine Learning
  • Recurrent Neural Networks
  • Recurrent Neural Networks
Artificial Intelligence icon1

Upcoming Class

7 days 27 Apr 2024

Machine Learning icon

Machine Learning

  • Introduction to Machine Learning & Python
  • Machine Learning: Supervised Learning
  • Machine Learning: Unsupervised Learning
Machine Learning icon1

Upcoming Class

-1 day 19 Apr 2024

 Tableau icon

Tableau

  • Introduction to Tableau Desktop
  • Data Transformation Methods
  • Configuring tableau server
  • Integration with R & Hadoop
 Tableau icon1

Upcoming Class

0 day 20 Apr 2024