SQL commands are categorized into four types:
- DDL (Data Definition Language):
- Defines and modifies database structure.
- Commands:
CREATE
,ALTER
,DROP
,TRUNCATE
. - Example:
CREATE TABLE students (id INT, name VARCHAR(50));
- DML (Data Manipulation Language):
- Handles data manipulation within tables.
- Commands:
INSERT
,UPDATE
,DELETE
,SELECT
. - Example:
INSERT INTO students VALUES (1, 'John');
- DCL (Data Control Language):
- Manages access permissions.
- Commands:
GRANT
,REVOKE
. - Example:
GRANT SELECT ON students TO user1;
- TCL (Transaction Control Language):
- Controls transactions.
- Commands:
COMMIT
,ROLLBACK
,SAVEPOINT
. - Example:
COMMIT;