0% found this document useful (0 votes)
6 views

Database

The document provides an overview of database languages, including Data Definition Language (DDL), Data Manipulation Language (DML), Data Control Language (DCL), and Transaction Control Language (TCL). It explains their functions, commands, and examples for creating, manipulating, and managing database structures and data. Mastery of these languages is essential for effective database administration and application development.

Uploaded by

22211a05l5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Database

The document provides an overview of database languages, including Data Definition Language (DDL), Data Manipulation Language (DML), Data Control Language (DCL), and Transaction Control Language (TCL). It explains their functions, commands, and examples for creating, manipulating, and managing database structures and data. Mastery of these languages is essential for effective database administration and application development.

Uploaded by

22211a05l5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

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

DDL DML DCL TCL


Data Definition Data Manipulation Data Control Transaction Control
Language Language Language Language
DDL stands for Data Definition Language. It is used to
define database structure or pattern.

DDL It is used to create schema, tables, indexes, constraints,


etc. in the database.
Data Definition Language Using the DDL statements, you can create the skeleton
of the database.
Data definition language is used to store the information
of metadata like the number of tables and schemas, their
names, indexes, columns in each table, constraints, etc.
DDL
COMMANDS
Create Alter
01 CREATE TABLE table_name (column1 02 ALTER TABLE table_name ADD COLUMN
data_type, column2 data_type, ...); column_name data_type;
ALTER TABLE table_name RENAME COLUMN
column_name TO new_column_name;
ALTER TABLE table_name DROP COLUMN
column_name;
Drop
03 DROP TABLE table_name;

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

You might also like