Database Languages in DBMS (DDL & DML)
Database Languages are special commands used to define, store, manipulate,
and control data in a database.
They provide a way for users and applications to interact with databases.
1. What are Database Languages?
Database languages are used to communicate with the database. They help in creating database structures, inserting data, retrieving data, and managing access control.
- Used to define database structure
- Used to manipulate stored data
- Used to control database access
2. Types of Database Languages
- DDL – Data Definition Language
- DML – Data Manipulation Language
- DCL – Data Control Language
- TCL – Transaction Control Language
3. Data Definition Language (DDL)
DDL is used to define and modify the structure of database objects such as tables, databases, indexes, and views.
🔹 Common DDL Commands
CREATE → Creates database objects ALTER → Modifies structure DROP → Deletes objects TRUNCATE → Removes all records RENAME → Renames database objects
🔹 Example (CREATE TABLE)
CREATE TABLE Student (
RollNo INT,
Name VARCHAR(50),
Marks INT
);
4. Data Manipulation Language (DML)
DML is used to insert, update, delete, and retrieve data stored in tables.
🔹 Common DML Commands
INSERT → Adds new records UPDATE → Modifies existing records DELETE → Removes records SELECT → Retrieves data
🔹 Example (INSERT & SELECT)
INSERT INTO Student VALUES (101, 'Amit', 78); SELECT * FROM Student;
5. Difference between DDL and DML
DDL DML ------------------------- -------------------------- Defines database structure Manipulates data Auto-commit Needs commit/rollback Affects schema Affects table data
6. Data Control Language (DCL)
DCL is used to control access to the database and provide authorization.
GRANT → Gives permission REVOKE → Removes permission
7. Transaction Control Language (TCL)
TCL is used to manage transactions in a database.
COMMIT → Save changes ROLLBACK → Undo changes SAVEPOINT → Set rollback point
8. Importance of Database Languages
- Easy interaction with database
- Ensures data integrity
- Supports multi-user environments
- Provides security and control
Practice Questions
- What are database languages?
- Explain DDL with examples.
- Explain DML with examples.
- Differentiate between DDL and DML.
- What is DCL and TCL?
Practice Task
Write SQL queries to:
✔ Create a table
✔ Insert records
✔ Update records
✔ Delete records
✔ Grant permission to a user