SQL BASIC


.


๐Ÿง  Part 1: Introduction to SQL (Structured Query Language)

๐Ÿ’ก What is SQL?

SQL (Structured Query Language) is the standard programming language used to manage and manipulate relational databases. With SQL, you can:

  • Create and modify database structures (schemas)

  • Insert, update, delete, and retrieve data

  • Control access to data (via permissions)

  • Analyze data using aggregation and filtering

SQL works with relational database systems like:

  • MySQL

  • PostgreSQL

  • SQLite

  • SQL Server

  • Oracle

SQL commands are grouped into five major categories:

CategoryDescriptionExample
DDL (Data Definition Language)Defines database structureCREATE, ALTER, DROP
DML (Data Manipulation Language)Deals with data modificationINSERT, UPDATE, DELETE
DQL (Data Query Language)Fetches dataSELECT
TCL (Transaction Control Language)Manages transactionsCOMMIT, ROLLBACK
DCL (Data Control Language)Manages access rightsGRANT, REVOKE


Part 2: Data Definition Language (DDL)

๐Ÿ”ธ 1. CREATE Statement

Used to create databases, tables, views, indexes, etc.

>> Syntax

CREATE TABLE table_name (

    column1 datatype,

    column2 datatype,

    ...

);

๐Ÿ“Œ Example:


CREATE TABLE Employees ( EmpID INT PRIMARY KEY, Name VARCHAR(100), Age INT, Department VARCHAR(50) );


๐Ÿ”ธ 2. ALTER Statement:

Modifies an existing table structure.

✅ Syntax:

SQL

ALTER TABLE table_name
ADD column_name datatype;

๐Ÿ“Œ Example:

SQL

ALTER TABLE Employees ADD Salary DECIMAL(10,2);


๐Ÿ”ธ 3. DROP Statement
Deletes a table or database permanently.

๐Ÿ“Œ Example:
SQL 

DROP TABLE Employees;

⚠️ Note: This statement used to delete all the data of the table.



๐Ÿงฑ Part 3: Data Manipulation Language (DML)

๐Ÿ”ธ 1. INSERT INTO

Adds new data into a table.

✅ Syntax:

SQL

INSERT INTO table_name (column1, column2, ...) VALUES (value1, value2, ...);

๐Ÿ“Œ Example:

INSERT INTO Employees (EmpID, Name, Age, Department) VALUES (101, 'Amit Sharma', 28, 'HR');

๐Ÿ”ธ 2. UPDATE

Modifies existing records in the table

✅ Syntax:

UPDATE table_name SET column1 = value1, column2 = value2, ... WHERE condition;

๐Ÿ“Œ Example

UPDATE Employees SET Salary = 55000 WHERE EmpID = 101;

NOTE: Always use WHERE to avoid updating all rows by mistake.


๐Ÿ”ธ 3. DELETE

Removes records from a table but the Structured of the table will remain same.

๐Ÿ“Œ Example:

DELETE FROM Employees WHERE Age < 25; (This will only delete the data <25)
but If you want to delete entire data from the Table)

QUERY: DELETE FROM TABLE_NAME




๐Ÿ” Part 4: Data Query Language (DQL)

๐Ÿ”ธ SELECT Statement

Used to retrieve data from a table.

✅ Syntax:


SELECT column1, column2 FROM table_name WHERE condition;

๐Ÿ“Œ Example:

SQL

SELECT Name, Department FROM Employees WHERE Salary > 50000;




Comments

Popular posts from this blog

2025 เคฎें เคซ्เคฐी เคฏा เค•เคฎ เค•ीเคฎเคค เคชเคฐ เคธ्เค•िเคฒ เคธीเค–เคจे เค•ी เคŸॉเคช เคตेเคฌเคธाเค‡เคŸ्เคธ | เคซ्เคฐी เค‘เคจเคฒाเค‡เคจ เค•ोเคฐ्เคธ เคตेเคฌเคธाเค‡เคŸ्เคธ เคนिंเคฆी เคฎें

C-DAC, Pune Invites online applications for various contractual positions at all levels for Pune/locations across India.