What is SQL and different Statements

  • by
sql-beginner-tutorial

Hi friends,

This is my very first attempt to teaching fields. So if I make any mistakes, sorry in the beginning….please don’t mind the mistakes….keep coding and learning.

This tutorial is #1 tutorial in SQL series. We will learn :

  1. What is SQL?
  2. Uses of SQL.
  3. Creating a new Database.
  4. Creating a table in SQL and its uses.
  5. Inserting a record in a table.
  6. Viewing Records stored in the table.
  7. Updating records in the table.
  8. Deleting the records.

What is SQL?

SQL stands for Structured Query Language. As the names implies, it is structured language to easily communicate with the system. Everything, every information is stored inside a table using which humans can easily read the records. SQL Database is a relational database. To understand what is relational database we first need to understand how is information stored inside SQL database.

Don’t worry. We will see this in 2nd tutorial of this series. For now let’s continue with this tutorial.

Uses of SQL:

SQL is basically used for storing records. This information can be really anything. Anything you can think you. Like Customer info….Students records…..Product records…..Universe data. NASA uses database to store information of the UNKNOWN. Area 51? May be. Joking.

Creating a new Database:

Database can be created using ‘Create database dbname’ in SQL. Example:

Create database DBStudents

use DBStudents

Creating a table in SQL and its uses:

In SQL we can create table using CREATE TABLE statement.

sql create table statement:

Create table tblStudents
(
Name nvarchar(50),
Surname nvarchar(50),
RollNo int,
DOB datetime
)

This will create table with name tblStudents.

Inserting a record in a table:

To add records using Query simply supply columns name along with its value in the insert statement.
Insert statement Example:

Insert into tblStudents (Name,Surname,RollNo,DOB)
Values ('Rick','Pointing','2','1993-12-28')
sql-beginner-tutorial

sql-beginner-tutorial

This will add a new record in our table.

Viewing Records stored in the table:

To view records stored inside SQL table use
Select statement.
Example:

Select * from tblStudents

Updating records in the table:

To update a record using Query supply columns name along with its update value in the update statement using where condition.
SQL Update statement:

Update tblStudents set RollNo=37 where Name='Rick'

Deleting the records:

To delete a record using Query supply use delete statement along with where condition.
Delete Example:

Delete from tblStudents where Name='Rick'

In the next tutorial we will learn What is primary key? What is Relational database using Example and Normalization.

Please Like our Facebook Page to help us grow.

[responsive-facebook-like-box]


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.