NOTE :
SchemaManipulate perform crud operation, aggregate function, join tablesGRANT permission and REVOKE permission accessTransaction flowselect , select with aggregate functionPurpose: Defines or modifies the structure of database objects like tables, indexes, schemas, etc.
Common Commands:
| Command | Description |
|---|---|
CREATE |
Create a new database, table, or other object |
ALTER |
Modify an existing object (e.g., add a column) |
DROP |
Delete an object (table, database, etc.) |
TRUNCATE |
Remove all rows from a table (faster than DELETE) |
Examples:
-- Create a table
CREATE TABLE Students (
id INT PRIMARY KEY,
name VARCHAR(50),
age INT
);
-- Add a new column
ALTER TABLE Students ADD email VARCHAR(100);
-- Delete a table
DROP TABLE Students;
-- Remove all data from table
TRUNCATE TABLE Students;
Purpose: Works with data inside the tables (CRUD operations).
Common Commands:
| Command | Description |
|---|---|
INSERT |
Add new rows to a table |
UPDATE |
Modify existing rows |
DELETE |
Remove rows |
SELECT |
Retrieve data |
Examples:
-- Insert data
INSERT INTO Students (id, name, age) VALUES (1, 'Alice', 20);
-- Update data
UPDATE Students SET age = 21 WHERE id = 1;
-- Delete data
DELETE FROM Students WHERE id = 1;
-- Select data
SELECT * FROM Students;
SELECT name, age FROM Students WHERE age > 18;