DEV Community

omar ab
omar ab

Posted on

The difference between the (DDL AND DML) DATABASE

Image description

DDL(Data Definition Language) and DML(Data Manipulation Language) are two important subsets of SQL (Structured Query Language), each serving different purposes in database management.

  • DDL
  1. CREATE: To create new tables or databases.
CREATE TABLE Employees (
    ID INT PRIMARY KEY,
    Name VARCHAR(100),
    Position VARCHAR(50)
);
Enter fullscreen mode Exit fullscreen mode
  1. ALTER: To modify existing database structures (e.g., adding or dropping columns).
ALTER TABLE table_name
ADD column_name data_type;
Enter fullscreen mode Exit fullscreen mode
  1. DROP: To delete tables or databases.
DROP TABLE table_name;
Enter fullscreen mode Exit fullscreen mode

DML

  1. SELECT: To query and retrieve data.
SELECT column1, column2, ...
FROM table_name;
Enter fullscreen mode Exit fullscreen mode
  1. INSERT: To add new records to a table.
INSERT INTO table_name (column1, column2, ...)
VALUES (value1, value2, ...);
Enter fullscreen mode Exit fullscreen mode
  1. UPDATE: To modify existing records.
UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;
Enter fullscreen mode Exit fullscreen mode
  1. DELETE: To remove records from a table.
DELETE FROM table_name
WHERE condition;
Enter fullscreen mode Exit fullscreen mode

Top comments (0)