SQL stands for Structured Query Language. It is a standard language used to communicate with relational databases.
SQL allows us to create databases and tables, store data, retrieve data, update existing data, delete data, and perform many other operations on structured data.
SQL is a language designed for working with relational databases. It provides commands that allow applications and users to interact with structured data.
For example, we can use SQL to retrieve all students from a students table:
SELECT * FROM students;
This query asks the database to return all columns and rows from the students table.
Applications often need to store large amounts of information. For example, a school application may need to store:
SQL provides a structured way to store and work with this data in a relational database.
A database is an organized collection of data. SQL provides commands for interacting with relational databases.
For example:
Database
|
├── students
├── courses
├── fees
└── attendance
Each table can contain related information.
Suppose we have a table named students:
id name course
1 Rahul Python
2 Priya SQL
3 Amit Java
We can retrieve the students using:
SELECT * FROM students;
We can also retrieve only the names:
SELECT name FROM students;
SQL can perform many database operations.
Some important SQL commands are:
CREATE
INSERT
SELECT
UPDATE
DELETE
ALTER
DROP
These commands are used for different database operations.
The SELECT statement is used to retrieve data from one or more tables.
SELECT name, course
FROM students;
This query retrieves the name and course columns from the students table.
The INSERT statement is used to add new records to a table.
INSERT INTO students
(name, course)
VALUES
('Rahul', 'Python');
This adds a new student record to the table.
The UPDATE statement changes existing records.
UPDATE students
SET course = 'SQL'
WHERE id = 1;
The WHERE condition identifies which record should be changed.
The DELETE statement removes records from a table.
DELETE FROM students
WHERE id = 1;
The WHERE clause limits the deletion to the matching record.
SQL keywords are reserved words that have special meaning in SQL statements.
Examples include:
SELECT
FROM
WHERE
INSERT
UPDATE
DELETE
CREATE
ALTER
DROP
ORDER BY
GROUP BY
An SQL statement is a complete instruction given to the database.
SELECT * FROM students;
The semicolon ; is commonly used to indicate the end of an SQL statement.
SQL is primarily associated with relational database systems. Relational databases organize data into tables and can define relationships between those tables.
Examples of relational database systems include:
SQL and MySQL are not the same thing.
| SQL | MySQL |
|---|---|
| SQL is a database language. | MySQL is a relational database management system. |
| SQL defines commands and syntax for working with relational data. | MySQL provides a database server that executes SQL statements. |
| SQL can be used with many relational database systems. | MySQL specifically refers to one database product. |
SQL is commonly used in applications that need structured data storage and retrieval.
SQL is frequently used as the database language in web applications. A web application can send SQL statements to a database through its backend code.
User
↓
Website
↓
Backend Application
↓
SQL Query
↓
Database
↓
Result
For example, a PHP or Python application can use SQL to retrieve student information from a database.
Consider a student management application. It may contain the following tables:
students
courses
fees
attendance
exams
The tables can contain related information and SQL can be used to retrieve and manage that information.
SQL is often used together with programming languages such as:
For example, Python can send SQL queries to a database and process the returned results.
In this SQL tutorial, you will gradually learn:
SQL Basics
↓
Database & Tables
↓
INSERT / SELECT / UPDATE / DELETE
↓
Filtering & Sorting
↓
Constraints
↓
Functions
↓
GROUP BY / HAVING
↓
JOINs
↓
Subqueries
↓
Views & Indexes
↓
Transactions
↓
Stored Procedures
↓
SQL Projects
Question: What does SQL stand for?