bg_image
header

Data Manipulation Language - DML

ChatGPT:

Data Manipulation Language (DML) is a subset of SQL (Structured Query Language) used to manage and manipulate data within a database. With DML, users can insert, query, update, and delete data — essentially everything you'd typically do with data stored in a database.

The main DML commands are:

Command Purpose
SELECT Retrieve data from a table
INSERT Add new data
UPDATE Modify existing data
DELETE Remove data
-- Insert
INSERT INTO customers (name, city) VALUES ('Müller', 'Berlin');

-- Query
SELECT * FROM customers WHERE city = 'Berlin';

-- Update
UPDATE customers SET city = 'Hamburg' WHERE name = 'Müller';

-- Delete
DELETE FROM customers WHERE name = 'Müller';

Key Points:

  • DML deals with the data inside tables, not with the structure of the tables themselves (that's handled by Data Definition Language, DDL).

  • DML operations can often be rolled back (undone), especially when transactions are supported.

In short: DML is the toolset you use to keep your database dynamic and interactive by constantly adding, reading, modifying, or deleting data.


Data Query Language - DQL

DQL stands for Data Query Language, and it's a subset of SQL (Structured Query Language). It is used specifically to query data from a database without modifying it.

Key Characteristics of DQL:

  • Read-only: DQL is used to retrieve data, not to insert, update, or delete it.

  • The primary command used is:

SELECT

Example:

SELECT name, birthdate FROM customers WHERE city = 'Berlin';

This command retrieves the names and birthdates of all customers living in Berlin — without changing any data.


DQL vs Other SQL Sub-languages:

Sub-language Meaning Main Purpose
DQL Data Query Language Reading data
DML Data Manipulation Language Inserting, updating, deleting data (INSERT, UPDATE, DELETE)
DDL Data Definition Language Defining database structure (CREATE, ALTER, DROP)
DCL Data Control Language Managing access rights (GRANT, REVOKE)
TCL Transaction Control Language Handling transactions (COMMIT, ROLLBACK)