Back to the 2021 paper

Unit 1: Database System Architecture

20217m

What are DDL and DML? Explain with the help of examples.

Worked SolutionAI Assisted

DDL and DML with Examples:

DDL (Data Definition Language): Defines/modifies schema structure. Auto-commit, no rollback. Commands:

  • CREATE TABLE Student(roll INT PRIMARY KEY, name VARCHAR(50));
  • ALTER TABLE Student ADD age INT;
  • DROP TABLE Student;
  • TRUNCATE TABLE Student;
  • CREATE INDEX idx_name ON Student(name);

DML (Data Manipulation Language): Manipulates data within structures. Needs COMMIT. Commands:

  • SELECT * FROM Student WHERE age >20;
  • INSERT INTO Student VALUES(1,'Amit',21);
  • UPDATE Student SET age=22 WHERE roll=1;
  • DELETE FROM Student WHERE roll=1;

DDL acts on metadata, DML on instances. DDL changes schema, DML queries/modifies rows.

Similar questions

Student FinanceWeb Platform

Pocketly — Personal Finance for Students

Keep your hostel and college expenses under control. Track accounts, log spending in seconds, and stay within your monthly budget.