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

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

рддेрд▓ рдЖрдгि рдиैрд╕рд░्рдЧिрдХ рд╡ाрдпू рдорд╣ाрдоंрдбрд│ाрдд (ONGC) 2236 рдЬाрдЧांрд╕ाрдаी рднрд░рддी.

Persistent is Hiring for Salesforce Developer for Hyderabad Location.