THE WORLD'S LARGEST WEB DEVELOPER SITE

What is SQL?


HTML

SQL stands for Structured Query Language

SQL is a standard language for accessing databases

SQL has been an international standard (ISO) since 1987


SQL Statements

To access a database, you use SQL statements.

The following SQL statement selects all records in a database table called "Customers":

Example

SELECT * FROM Customers;
Try it Yourself »

Database Tables

A database most often contains one or more tables.

Each table is identified by a name like "Customers" or "Orders".

Below is a selection from a "Customers" table:

ID CustomerName ContactName Address City PostalCode Country
1

Alfreds Futterkiste Maria Anders Obere Str. 57 Berlin 12209 Germany
2 Ana Trujillo Emparedados y helados Ana Trujillo Avda. de la Constitución 2222 México D.F. 05021 Mexico
3 Antonio Moreno Taquería Antonio Moreno Mataderos 2312 México D.F. 05023 Mexico
4

Around the Horn Thomas Hardy 120 Hanover Sq. London WA1 1DP UK
5 Berglunds snabbköp Christina Berglund Berguvsvägen 8 Luleå S-958 22 Sweden

The table above contains five records (one for each customer) and seven columns:

  1. CustomerID (ID)
  2. CustomerName
  3. ContactName
  4. Address
  5. City
  6. PostalCode
  7. Country

The Most Important SQL Statements:

  • SELECT - extracts data from a database
  • UPDATE - updates data in a database
  • DELETE - deletes data from a database
  • INSERT INTO - inserts new data into a database
  • CREATE DATABASE - creates a new database
  • ALTER DATABASE - modifies a database
  • CREATE TABLE - creates a new table
  • ALTER TABLE - modifies a table
  • DROP TABLE - deletes a table
  • CREATE INDEX - creates an index (search key)
  • DROP INDEX - deletes an index

SQL keywords are NOT case sensitive: select is the same as SELECT


Full SQL Tutorial

This has been a short introduction to SQL.

For a full SQL tutorial go to W3Schools SQL Tutorial.