SQL Tutorial · SQL Basics · Lesson 1 of 36
SQL Introduction
What SQL is, what relational databases are and how this tutorial's examples work.
What is SQL?
SQL (Structured Query Language, pronounced "S-Q-L" or "sequel") is the standard language for working with relational databases — PostgreSQL, MySQL, SQL Server, Oracle, SQLite and many more. With SQL you can:
- query data (
SELECT), - add, change and remove data (
INSERT,UPDATE,DELETE), - define tables and their rules (
CREATE TABLE), - control access and transactions.
Tables, rows and columns
A relational database stores data in tables. Each row is one record (one customer, one order) and each column is one attribute (name, email, price). Tables are linked through keys — for example, every order stores the customer_id of the customer who placed it.
Your first query
SELECT name, city FROM customers;
Output
name | city Ada Lovelace | London Alan Turing | Manchester Grace Hopper | New York Linus Torvalds | Portland Margaret Hamilton | Boston Tim Berners-Lee | Geneva Barbara Liskov | NULL Guido van Rossum | Amsterdam Yukihiro Matsumoto | Tokyo Katherine Johnson | Hampton
Running SQL on this site
Every example runs on a real SQLite database inside your browser, loaded with a small shop and company dataset — see The Sample Database. Each run starts from a fresh copy, so feel free to INSERT, UPDATE and DELETE. The SQL you learn here works almost identically in PostgreSQL and MySQL; differences are pointed out where they matter.
Test yourself
Which SQL statement reads data from a table?
GETREADSELECTFETCH
Show answer
Answer: SELECT