Notes – Introduction to SQL
Structured Query Language (SQL) is the standard language used to interact with relational databases. It helps us store, retrieve, manage, and manipulate data in a structured format.
What is SQL?
- SQL stands for Structured Query Language
- It is used to communicate with Relational Database Management Systems (RDBMS)
- Examples of popular RDBMS: MySQL, PostgreSQL, Oracle, SQL Server
Why do we use SQL?
SQL helps you:
- Create databases and tables
- Insert, update, and delete data
- Fetch specific data using queries
- Apply conditions and filters to data
- Set permissions and manage access
- Perform analytics and reporting
Real-Life Analogy
Think of SQL as a language to ask questions to a data warehouse.
For example:
You walk into a library (database) and ask:
โShow me all the books written by ‘Author A’ after 2015.โ
That question is a SQL query.
Basic SQL Operations (CRUD)
| Operation | SQL Command | Description |
|---|---|---|
| Create | INSERT | Add new data into a table |
| Read | SELECT | Retrieve data from one or more tables |
| Update | UPDATE | Modify existing data |
| Delete | DELETE | Remove data from a table |
SQL is Declarative
- SQL tells what to do, not how to do it
- You define the result, and the system decides the best way to get it
- Example: sqlCopyEdit
SELECT name FROM students WHERE grade > 80;Youโre saying what you want โ not how to fetch it behind the scenes
What SQL is NOT
- Itโs not a programming language like Python or Java
- It doesnโt handle application logic or UI design
- Itโs focused only on managing data
Quick Example
Hereโs a basic SQL query:
SELECT first_name, last_name
FROM employees
WHERE department = 'HR';
This means: โGet the first and last names of employees who work in the HR department.โ
