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 :
- What is SQL?
- Uses of SQL.
- Creating a new Database.
- Creating a table in SQL and its uses.
- Inserting a record in a table.
- Viewing Records stored in the table.
- Updating records in the table.
- 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')
This will add a new record in our table.
Viewing Records stored in the table:
To view records stored inside SQL table use
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 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.