EXtraQuery
EXtraQuery
(Structured Query Language) used in database management. They serve distinct purposes related to the
structure and content of a database.
DDL is used to define and manage the structure of a database, including tables, schemas, and other
objects. It is concerned with creating, altering, and deleting database objects such as tables and indexes.
Purpose:
CREATE: Used to create new objects like tables, databases, views, etc.
Example:
Name VARCHAR(100),
Department VARCHAR(50),
Salary DECIMAL(10, 2)
);
- Example:
Example:
Example:
DML is used to manipulate and manage data within existing database objects. It focuses on CRUD
operations (Create, Read, Update, Delete).
Purpose:
It doesn't alter the structure of the database but only the data it contains.
Example:
Example:
Example:
UPDATE Employees
WHERE EmployeeID = 1;
Example:
WHERE EmployeeID = 1;
Summary of Purpose:
Each serves an essential role in database management: DDL for setting up and modifying the schema,
and DML for managing the data stored within that schema.
SQL (Structured Query Language) can be broken down into several key concepts, including relational
algebra, aggregate functions, and set operations. Here's a quick breakdown of each:
Relational algebra provides a foundation for SQL, using a set of operations to manipulate data in
relational databases. SQL commands essentially translate into these algebraic operations.
- Union (⋃): Combines the result set of two queries (removes duplicates).
- Set Difference (-): Returns rows in one query but not in another.
- Cartesian Product (×): Combines every row from one table with every row of another.
- Join (⨝): Combines rows from two or more tables based on a related column.
SELECT * FROM table1 INNER JOIN table2 ON table1.column = table2.column;
Aggregate functions perform a calculation on a set of values and return a single value. They're often
used with the GROUP BY clause.
UNION
UNION ALL
INTERSECT
- EXCEPT: Returns rows from the first query that are not in the second query.
EXCEPT
These concepts form the backbone of SQL query structure, allowing you to perform complex data
manipulation and analysis.