SQL (Structured Query Language) là ngôn ngữ chuẩn để làm việc với DB quan hệ (PostgreSQL, MySQL, SQLite). Lệnh chia thành 4 nhóm:
- DDL (định nghĩa cấu trúc):
CREATE,ALTER,DROP. - DML (thao tác dữ liệu):
SELECT,INSERT,UPDATE,DELETE. - DCL (phân quyền):
GRANT,REVOKE. - TCL (giao dịch):
BEGIN,COMMIT,ROLLBACK.
Thực tế: dev dùng DML ~90% thời gian, DDL khi migration; DCL/TCL thường do DBA/DevOps. Nắm phân loại này giúp debug lỗi phân quyền và viết migration đúng.
SQL (Structured Query Language) is the standard language for working with relational DBs (PostgreSQL, MySQL, SQLite). Commands fall into 4 groups:
- DDL (defines structure):
CREATE,ALTER,DROP. - DML (manipulates data):
SELECT,INSERT,UPDATE,DELETE. - DCL (permissions):
GRANT,REVOKE. - TCL (transactions):
BEGIN,COMMIT,ROLLBACK.
In practice: devs use DML ~90% of the time, DDL during migrations; DCL/TCL are usually handled by DBAs/DevOps. Knowing this split helps you debug permission errors and write correct migrations.