SQL Syntax and Structure
SQL syntax is the set of rules that defines how SQL statements should be written and structured. Each SQL command typically begins with a keyword such as SELECT, INSERT, UPDATE, etc., and follows a specific format.
1. SELECT Statement
SELECT column1, column2
FROM table_name
WHERE condition
ORDER BY column1 ASC;
Purpose: Retrieves specific data from one or more tables.
2. INSERT Statement
INSERT INTO table_name (column1, column2)
VALUES ('value1', 'value2');
Purpose: Adds new records to a table.
3. UPDATE Statement
UPDATE table_name
SET column1 = 'value1'
WHERE condition;
Purpose: Modifies existing records.
4. DELETE Statement
DELETE FROM table_name
WHERE condition;
Purpose: Removes records based on a condition.
5. CREATE TABLE Statement
CREATE TABLE employees (
id INT PRIMARY KEY,
name VARCHAR(100),
age INT,
department VARCHAR(50)
);
Purpose: Defines a new table and its structure.
SQL Syntax Rules
- SQL is case-insensitive, but keywords are usually written in uppercase for readability.
- Statements end with a semicolon
;. - String values are enclosed in single quotes:
'value'. - SQL follows a declarative style — you state *what* you want, not *how* to do it.
- Comments can be added using
--for single line or/* ... */for block comments.


