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.

DatabaseMade byTypical use
MySQLOracle (open source)Web applications, WordPress, startups
PostgreSQLOpen source communityFeature-rich apps, analytics, GIS
SQL ServerMicrosoftEnterprise and .NET applications
Oracle DatabaseOracleLarge enterprises, banking
SQLiteOpen sourceMobile 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

CustomerIDCustomerNameContactNameCityCountry
1Aarav TradersAarav ShahMumbaiIndia
2Blue Harbor FoodsEmma ClarkLondonUK
3Cedar & CoLiam BrownTorontoCanada
4Delta MartPriya NairBengaluruIndia
5Evergreen GrocersNoah WilsonNew YorkUSA
6Fjord SuppliesIngrid OlsenOsloNorway
7Golden SpoonMei ChenNULLSingapore
8Harbor LightsOlivia MartinLondonUK