Database
Database
Languages
Nipun Lingadally
Nomula Nagarjuna Reddy
Rishindra Nyalakanti
Sai Varshitha Panthangi
Samanvita Maddula
Table of
CONTENTS
01 02 03
Introduction Types of Database DDL
Languages
04 05 06
DML DCL TCL
INTRODUCTION
Database languages facilitate interaction with databases, allowing
users to define, query, update, and manage data. They establish data
structure through commands for table creation, data type specification,
and constraint definition. Users manipulate data via commands for
inserting, retrieving, updating, and deleting records. These languages
also support transaction management for ensuring data consistency,
with commands like `COMMIT` and `ROLLBACK`. Mastery of database
languages is essential for effective database administration and
application development, enabling efficient data management and
utilization within a secure environment.
Database
LANGUAGES
Truncate
04 TRUNCATE TABLE table_name;
Rename
05 RENAME TABLE old_table_name TO
new_table_name;
Example for
DDL
Create
CREATE TABLE Employees ( EmployeeID INT PRIMARY KEY,
FirstName VARCHAR(50) NOT NULL, LastName
VARCHAR(50) NOT NULL, Email VARCHAR(100) UNIQUE,
Salary DECIMAL(10,2) );
Alter
Add Colum
ALTER TABLE Employees ADD PhoneNumber VARCHAR(20);
Rename Column
ALTER TABLE Employees RENAME COLUMN FirstName TO
Name;
Drop Column
ALTER TABLE Employees DROP COLUMN Salary;
Drop
DROP TABLE Employees;
Truncate
TRUNCATE TABLE Employees;
Rename
RENAME TABLE old_table_name TO
new_table_name;
DML
DML stands for Data Manipulation Language. It is used for
accessing and manipulating data in a database.
It handles user requests.
Data Manipulation Language It is used to insert, update, and delete data from tables.
DML
COMMANDS
Select Insert
01 SELECT * FROM table_name; 02 INSERT INTO table_name (column1, column2, ...)
VALUES (value1, value2, ...);
Update Delete
03 UPDATE table_name SET column1 = 04 DELETE FROM table_name WHERE
value1, column2 = value2 WHERE condition;
condition;
Example for
DML
Select
No Rows Selected
SELECT * FROM Employees;
Insert
INSERT INTO Employees (EmployeeID, Name,
LastName, Email, PhoneNumber)
VALUES (1, 'John', 'Doe',
'[email protected]', 123-456-7890);
Update
UPDATE Employees
SET PhoneNumber = 152-784-8569
WHERE EmployeeID = 1;
Delete
DELETE FROM Employees No Rows Selected
WHERE EmployeeID = 1;
DCL stands for Data Control Language. It is used to
retrieve the stored or saved data.
DCL DCL is used to control access to the database.
It is used to manage permissions and access control for
Data Control Language the database.
The DCL execution is transactional. It also has rollback
parameters.
(But in Oracle database, the execution of data control
language does not have the feature of rolling back.)
DCL
COMMANDS
Grant
01 GRANT privilege_name ON object_name TO user_name;
Revoke
02 REVOKE privilege_name ON object_name FROM user_name;
Example for
DCL
Grant
GRANT SELECT ON Employees TO user1;
Revoke
REVOKE SELECT ON Employees FROM user1;
TCL is used to run the changes made by the DML
TCL statement.
TCL can be grouped into a logical transaction.
Transition Control Language TCL is used to manage transactions in the database.
It is used to save and restore the previous state of the
database.
TCL
COMMANDS
Commit
01 COMMIT;
Rollback
02 ROLLBACK;
Example for
TCL
Commit
BEGIN TRANSACTION;
UPDATE Employees
SET Email = '[email protected]'
WHERE EmployeeID = 1;
COMMIT;
Rollback
BEGIN TRANSACTION;
UPDATE Employees
SET Email = '[email protected]'
WHERE EmployeeID = 1;
ROLLBACK;
THANK YOU