Learn SQL Syntax, CRUD Operations, Data Types & Commands for Beginners
Master the fundamentals of SQL with this beginner-friendly guide. Learn SQL syntax, CRUD operations (Create, Read, Update, Delete), essential data types like INT, VARCHAR, DATE, DECIMAL, BOOLEAN, and key commands such as CREATE, SELECT, INSERT, UPDATE, and DELETE. Practice by creating an Employees table and performing real SQL operations.
1. What is SQL?
SQL (Structured Query Language) is the standard language used to interact with relational databases. It allows you to create, read, update, and delete data efficiently.
Key Points:
- SQL is used in databases like MySQL, SQL Server, PostgreSQL, and Oracle.
- It organizes data in tables, rows, and columns.
- Supports querying, data manipulation, and management.
2. SQL Syntax
- SQL statements are usually case-insensitive, but keywords are written in uppercase for clarity.
- General structure of a query:
Example:
3. CRUD Operations
CRUD stands for the four basic operations in SQL:
| OperationSQL CommandPurpose | ||
| Create | INSERT | Add new records |
| Read | SELECT | Retrieve records |
| Update | UPDATE | Modify existing records |
| Delete | DELETE | Remove records |
4. Common SQL Data Types
| Data TypeDescriptionExample | ||
| INT | Integer numbers | 1, 100, 5000 |
| VARCHAR | Variable-length text | 'Alice', 'HR' |
| DATE | Date values | '2025-12-05' |
| DECIMAL | Decimal/floating numbers | 123.45 |
| BOOLEAN | True/False values | TRUE, FALSE |
5. Essential SQL Commands
5.1 Create and Drop Database
5.2 Create, Alter, and Drop Table
5.3 Insert Records
5.4 Retrieve Records
5.5 Update Records
5.6 Delete Records
6. Practical Exercises
- Create a table
Employeeswith columns:ID,Name,Department,Salary. - Insert 3–5 employee records.
- Update the salary of an employee.
- Delete an employee record.
- Retrieve all records from the table.
- Try selecting specific columns and filtering records using WHERE.
7. Tips for Beginners
- Always use primary keys for unique identification.
- Use meaningful column names for clarity.
- Keep practicing CRUD operations with different datasets.
- Use comments in SQL for better readability: