getting-started

Introduction to SQL

Start learning SQL — the standard language for storing, retrieving, and managing data in relational databases.

SQL Tutorial

SQL is the standard language for accessing and manipulating databases. With our hands-on lessons and runnable examples, you'll be writing real queries in minutes.

Examples in Each Chapter

With our online SQL editor, you can edit the SQL statements, and click on a button to view the result.

SELECT * FROM Customers;

Click on the Try it Yourself button above to see how it works.

What is SQL?

  • SQL stands for Structured Query Language
  • SQL lets you access and manipulate databases
  • SQL became a standard of the American National Standards Institute (ANSI) in 1986, and of the International Organization for Standardization (ISO) in 1987
  • Almost every database you'll ever work with — MySQL, PostgreSQL, SQL Server, Oracle, SQLite — speaks SQL

What Can SQL Do?

  • SQL can execute queries against a database
  • SQL can retrieve data from a database
  • SQL can insert records into a database
  • SQL can update records in a database
  • SQL can delete records from a database
  • SQL can create new databases and tables
  • SQL can set permissions on tables, procedures, and views

SQL is a Standard — BUT...

Although SQL is an ANSI/ISO standard, there are different versions of the SQL language. However, to be compliant with the standard, they all support at least the major commands (such as SELECT, UPDATE, DELETE, INSERT, WHERE) in a similar manner.

Note: Most of the SQL database programs also have their own proprietary extensions in addition to the SQL standard.

Using SQL in Your Web Site

To build a web site that shows data from a database, you will need:

  • An RDBMS database program (such as MS Access, SQL Server, MySQL)
  • A server-side scripting language, like PHP or Node.js
  • SQL to get the data you want
  • HTML / CSS to style the page

RDBMS

RDBMS stands for Relational Database Management System. It is the basis for SQL, and for all modern database systems such as MS SQL Server, IBM DB2, Oracle, MySQL, and Microsoft Access.

The data in RDBMS is stored in database objects called tables. A table is a collection of related data entries and it consists of columns and rows.

The SELECT * Wildcard

Look at the example query at the top of this lesson again:

SELECT * FROM Customers;

The * (asterisk) is a SQL wildcard meaning "every column". SELECT * FROM Customers returns all rows and all columns from the Customers table — it's the shortest possible way to dump a table's contents.

You'll see this pattern everywhere. It's perfect for exploring a table, but in production code you should usually list the columns you actually need:

SELECT CustomerName, City FROM Customers;

This returns only the two columns specified — faster, more bandwidth-efficient, and survives schema changes.

What's Next

In the next lesson, Why SQL Matters, you'll see three real industry scenarios where a single SQL query replaces hours of glue code.

Introduction to SQL — SQL Mastery — From Zero to Joins