What is SQL?
SQL (Structured Query Language, pronounced "ess-que-el" or "sequel") is the standard language for storing, reading, changing and deleting data in a relational database.
Almost every application you use, from banking apps to job portals, keeps its data in a relational database and talks to it with SQL.
What Can SQL Do?
- Retrieve data from a database (
SELECT) - Insert, update and delete records (
INSERT,UPDATE,DELETE) - Create new databases, tables, views and indexes (
CREATE) - Change the structure of existing tables (
ALTER) - Control who can see or change data (
GRANT,REVOKE) - Group several changes into one safe unit of work (
COMMIT,ROLLBACK)
SQL is a Standard, With Dialects
SQL became an ANSI standard in 1986 and an ISO standard in 1987. Every major database supports the core commands (SELECT, UPDATE, DELETE, INSERT, WHERE) in the same way, but each product adds its own extensions.
| Database | Made by | Typical use |
|---|---|---|
| MySQL | Oracle (open source) | Web applications, WordPress, startups |
| PostgreSQL | Open source community | Feature-rich apps, analytics, GIS |
| SQL Server | Microsoft | Enterprise and .NET applications |
| Oracle Database | Oracle | Large enterprises, banking |
| SQLite | Open source | Mobile apps, browsers, embedded devices |
Note: The examples in this tutorial use standard SQL. Where databases differ (for example LIMIT vs TOP), the page shows each version.
Your First Query
The statement below reads every row from a table called Customers. Press Run on any example to open it in the code runner with the demo tables already created.
Example
Select all records from the Customers table:
SELECT * FROM Customers;Result: 8 rows
| CustomerID | CustomerName | ContactName | City | Country |
|---|---|---|---|---|
| 1 | Aarav Traders | Aarav Shah | Mumbai | India |
| 2 | Blue Harbor Foods | Emma Clark | London | UK |
| 3 | Cedar & Co | Liam Brown | Toronto | Canada |
| 4 | Delta Mart | Priya Nair | Bengaluru | India |
| 5 | Evergreen Grocers | Noah Wilson | New York | USA |
| 6 | Fjord Supplies | Ingrid Olsen | Oslo | Norway |
| 7 | Golden Spoon | Mei Chen | NULL | Singapore |
| 8 | Harbor Lights | Olivia Martin | London | UK |