Introduction to SQL

SQL Tutorial

Introduction to SQL (Beginner-Friendly Guide)

SQL (Structured Query Language) is a standard language used to store, retrieve, manage, and manipulate data in relational databases.
It is essential for backend development, data analysis, and interviews.


 What is SQL?

SQL is a query language used to communicate with a database.

With SQL, you can:

  • Create databases & tables

  • Insert, update, delete data

  • Retrieve data using queries

  • Control access & security


 What is a Database?

A database is an organized collection of data stored in tables.

Example: students table

idnamemarks
1Rahul85
2Ankit90
  • Rows = records
  •  Columns = fields

 Why Learn SQL?

  • Used in almost every application

  • Required for backend & full-stack

  • Core skill for data analyst / data science

  • Extremely common in interviews

  • Works with many databases (MySQL, PostgreSQL, Oracle, SQL Server)


 Types of SQL Commands

SQL commands are grouped into 5 main categories:


 1. DDL (Data Definition Language)

Used to define database structure.

CommandPurpose
CREATECreate table/database
ALTERModify table
DROPDelete table/database
TRUNCATERemove all records

 


2. DML (Data Manipulation Language)

Used to manipulate data.

CommandPurpose
INSERTAdd data
UPDATEModify data
DELETERemove data

 


 3. DQL (Data Query Language)

Used to fetch data.

CommandPurpose
SELECTRetrieve data

 


4. DCL (Data Control Language)

Used to control access.

CommandPurpose
GRANTGive permission
REVOKERemove permission

 5. TCL (Transaction Control Language)

Used to manage transactions.

CommandPurpose
COMMITSave changes
ROLLBACKUndo changes
SAVEPOINTCreate rollback point

 Basic SQL Syntax Rules

  • SQL keywords are NOT case-sensitive

    SELECT * FROM students;
    select * from students;
  • End statements with semicolon ;

  • Strings are written in single quotes

    'Rahul'

 Common SQL Data Types

TypeDescription
INTInteger number
FLOATDecimal number
VARCHAR(n)String
DATEDate
BOOLEANTrue / False

 Basic SQL Queries (Examples)

Select specific columns


 


Filter data using WHERE


 


Sort data using ORDER BY


 


 SQL vs NoSQL (Quick Comparison)

SQLNoSQL
Table-basedDocument / Key-Value
Fixed schemaFlexible schema
Structured dataUnstructured data
Uses SQLUses APIs / JSON

 Where SQL is Used?

  • Banking systems

  • E-commerce websites

  • Hospital management

  • School/college systems

  • Backend servers

  • Data analytics & reporting


 Common Beginner Mistakes

  •  Forgetting WHERE condition in DELETE 
  •  Using double quotes instead of single quotes
  •  Confusing DELETE and TRUNCATE 
  •  Not understanding primary keys

 Interview Questions (Must Prepare)

  1. What is SQL?

  2. Difference between SQL and DBMS?

  3. What are DDL, DML, DQL?

  4. What is a primary key?

  5. Difference between DELETE and TRUNCATE?

  6. What is SELECT *?


 Summary

  •  SQL is used to interact with databases
  •  Data is stored in tables (rows & columns)
  •  SQL commands are grouped into DDL, DML, DQL, DCL, TCL
  • SELECT is the most used command
  •  Essential for backend, data, and interviews

You may also like...