DEV Community

omar ab
omar ab

Posted on

1

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

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay