Q1. What is SQL and what are its main components?
basicAnswer
SQL (Structured Query Language) is used to communicate with databases. Main components: DDL (CREATE, ALTER, DROP - structure), DML (SELECT, INSERT, UPDATE, DELETE - data), DCL (GRANT, REVOKE - permissions), TCL (COMMIT, ROLLBACK - transactions).
Example Code
1-- DDL: Create structure
2CREATE TABLE students (id INT, name VARCHAR(100));
3
4-- DML: Manipulate data
5INSERT INTO students VALUES (1, 'John');
6SELECT * FROM students;
7
8-- DCL: Control access
9GRANT SELECT ON students TO app_user;
10
11-- TCL: Transaction control
12BEGIN; UPDATE students SET name = 'Jane' WHERE id = 1; COMMIT;