SQL the Language of Data
SQL the Language of Data
SQL uses reserved keywords like SELECT, INSERT, SQL defines various data types for different data,
UPDATE, DELETE, and WHERE to perform specific including INT, VARCHAR, DATE, and BOOLEAN, to
operations. These keywords are case-insensitive. ensure data integrity and efficient storage.
SQL Data Types
Numeric Text
INT, FLOAT, DECIMAL, etc., VARCHAR, CHAR, TEXT, etc.,
for storing numbers with for storing character strings.
different precision.
Data Definition Language (DDL)Data Manipulation Language Data Control Language (DCL)
(DML)
Commands like CREATE, ALTER, and Commands like GRANT and REVOKE
DROP manage database structure. Commands like SELECT, INSERT, control user access and permissions.
UPDATE, and DELETE modify data
within tables.
SQL Select Statement
1 SELECT
Specifies the columns to retrieve from the table.
2 FROM
Identifies the table to retrieve data from.
3 WHERE
Applies conditions to filter data.
4 ORDER BY
Sorts the results in ascending or descending order.
SQL Insert, Update, and
Delete
INSERT
Adds new rows to a table.
UPDATE
Modifies existing data in a table.
DELETE
Removes rows from a table.
SQL Joins
INNER JOIN
1 Returns rows matching in both tables.
LEFT JOIN
2
Returns all rows from the left table, matching or not.
RIGHT JOIN
3
Returns all rows from the right table, matching or not.
FULL JOIN
4
Returns all rows from both tables.
SQL Subqueries
Nested Query
1
A query embedded within another query.
Purpose
2
Used to filter or retrieve data based on the results of another query.
Example
3
Finding employees who earn more than the average salary.
SQL Stored Procedures
1 2
Pre-compiled Code Reusable
Stored within the database for Can be called multiple times
efficient execution. without rewriting the code.
3
Improved Security
Offers greater control and
security for data access.
Companies Using SQL Databases