Course Content
Detailed Content of Database Management System
0/1
About Lesson

In SQL (Structured Query Language), queries are broadly categorized into three main types based on their functionality: Data Definition Language (DDL), Data Manipulation Language (DML), and Data Control Language (DCL). Each type serves a specific purpose in managing and interacting with a relational database.


DDL statements are used to define, modify, or delete the structure of database objects. These objects include tables, indexes, views, and schemas. DDL statements do not deal with the actual data but focus on the database’s structure.

Common DDL statements include:

Used to create a new database object, such as a table or index.

SQL
CREATE TABLE Employees (
    EmployeeID INT PRIMARY KEY,
    FirstName VARCHAR(50),
    LastName VARCHAR(50)
);

Used to modify the structure of an existing database object.

SQL
ALTER TABLE Employees
ADD COLUMN BirthDate DATE;

Used to delete an existing database object.

SQL
DROP TABLE Employees;

DML statements are used to manipulate the data stored in the database. These statements enable the insertion, updating, and deletion of records in tables.

Common DML statements include:

Used to retrieve data from one or more tables.

SQL
SELECT * FROM Employees WHERE DepartmentID = 1;

Used to add new records into a table.

SQL
INSERT INTO Employees (EmployeeID, FirstName, LastName)
VALUES (1, 'John', 'Doe');

Used to modify existing records in a table.

SQL
UPDATE Employees
SET FirstName = 'Jane'
WHERE EmployeeID = 1;

Used to remove records from a table.

SQL
DELETE FROM Employees
WHERE EmployeeID = 1;

DCL statements are used to control access to data within the database. These statements manage permissions and privileges related to security and access control.

Common DCL statements include:

Used to create a new database object, such as a table or index.

Used to give specific privileges to users or roles.

SQL
GRANT SELECT, INSERT ON Employees TO HR_User;

Used to take away specific privileges from users or roles.

SQL
REVOKE DELETE ON Employees FROM HR_User;

It’s important to note that some database systems may have additional or proprietary extensions to these standard SQL statements. Additionally, the specific syntax and functionality of SQL statements can vary between database management systems (DBMS) such as MySQL, PostgreSQL, SQL Server, and Oracle.