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:
Category | Description | Example |
---|---|---|
DDL (Data Definition Language) | Defines database structure | CREATE , ALTER , DROP |
DML (Data Manipulation Language) | Deals with data modification | INSERT , UPDATE , DELETE |
DQL (Data Query Language) | Fetches data | SELECT |
TCL (Transaction Control Language) | Manages transactions | COMMIT , ROLLBACK |
DCL (Data Control Language) | Manages access rights | GRANT , 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:
ЁЯФ╕ 2. ALTER Statement:
Modifies an existing table structure.
✅ Syntax:
ЁЯУМ Example:
ЁЯз▒ Part 3: Data Manipulation Language (DML)
ЁЯФ╕ 1. INSERT INTO
Adds new data into a table.
✅ Syntax:
ЁЯУМ Example:
ЁЯФ╕ 2. UPDATE
Modifies existing records in the table
✅ Syntax:
ЁЯУМ Example
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:
ЁЯФН Part 4: Data Query Language (DQL)
ЁЯФ╕ SELECT Statement
Used to retrieve data from a table.
✅ Syntax:
ЁЯУМ Example:
Comments
Post a Comment