SQL Resources

SQL, or Structured Query Language, is a language used by relational database management systems (RDBMSes) for defining data structures, updating data, and querying data.

The vast majority of relational database systems use some form of SQL, making "SQL database" and "relational database" effectively synonymous in everyday conversation.

Here we have collected a definitive list of the best SQL tutorials, guides, books and more.

These are the major implementations of the SQL language. Each one has its own peculiarities and its own deviations from the standard. Some of them do not implement every aspect of the SQL standard, and some provide additional features and syntax.

Open Source

  • MySQL: by far the most commonly used Open Source SQL database system in the world. MySQL is used by a number of very popular web applications such as WordPress and Drupal, and is the M in the LAMP stack.
  • PostgreSQL: the major alternative to MySQL in the Open Source RDBMS space. Many see it as a more advanced, better designed database.
  • MariaDB: a drop-in replacement for MySQL, with increased performance and additional features. It began as a fork of MySQL, under the care of a group of mostly former-MySQL developers.
  • SQLite: a library that can be included into a larger code base, not a fully-featured database management system. It provides SQL-based data storage for applications.

Proprietary

Books on SQL

You can learn a little bit of SQL from online tutorials, but the information you need to be a real database professional is mostly found in books.

General SQL

  • Learning SQL: good book for those first getting into the language.
  • SQL: The Complete Reference: detailed reference to SQL, considered the "standard" for the last 30 years.
  • The Art of SQL: an excellent book that explains how to think about data modeling, schema design, and database querying.
  • SQL Antipatterns: Avoiding the Pitfalls of Database Programming: This books details the many ways that people habitually misuse and poorly manage relational databases, along with help diagnosing and fixing each common problem. This is one of the best books on real-life database issues — essential for any database developer.

Once you've read one or two books on introductory SQL, you should dive into one of the specific implementations (see resources below) and work through an actual project. Then come back and look at some more theory and general principles.

Data Modeling (Database Schema Design)

Not all of these resources are about SQL specifically, but about the larger topic of data modeling. One of the most important aspects of writing SQL code is designing the schema for a database. To do this well, you must have a firm grasp on the underlying philosophy, art, and science of data modeling.

Data Querying and Analysis

Setting up your data structures properly, and filling your database with good, solid data are both critically important. But once you have all this data, what do you do with it? These books will help you learn how to do more than SELECT *, teaching you to create efficient and insightful queries that provide the data you really need.

Advanced SQL Programming

Here are a couple of books for database administrators and data professionals.

SQL Performance and Optimization

The prerequisites for high performance database designs are excellent data modeling and well-designed queries. So make sure you read the books from those sections before you start looking at advanced optimization techniques.

Also, be aware that many of the most powerful optimization techniques are implementation-specific. See the relevant sections below for books and resources about each of the major SQL implementations.

Data Science and Mathematics

Relational database theory is based on a branch of mathematics call "Relational Algebra." Most SQL practitioners don't need to explore the math behind SQL. But if you are interested in a deep dive into data science, these books will help you find your way.

Books on Specific SQL Implementations

SQL is a standard, but it only exists in specific implementations. Each one has its own quirks. If you want to become a real database professional, you'll need to know the particulars of the specific RDBMS you are dealing with.

Online Resources

Although they may not provide quite the depth of the best books, there are a lot of very useful resources online.

Tutorials

Unfortunately, there are not a lot of really great online tutorials for SQL. The courses listed here are a great place to start as a beginner, but if you are serious about learning SQL, you'll need to scroll up to the books section and buy some dead-tree resources.

SQL Language Reference

It is useful to have a handy online reference for your particular implementation while in the middle of a coding job. None of these work particularly well as tutorials for learning SQL (unless you like reading reference material), but they are great for consulting when you need to know how a particular command works.

SQL and Database Management Tools

Very few people really enjoy writing raw SQL code with their bare hands. These tools provide a range of interface features for handling database design and management in a more friendly and efficient manner.

Online Communities

Sometimes the best way to find something out is to ask an expert. There are a number of online communities where you can talk to other SQL practitioners and get help, advice, encouragement, and moral support.

SQL professionals should have at least some familiarity with the following related concepts and technologies.

FAQ

Here are the answers to a few frequently asked questions.

What is SQL?

SQL, or Structured Query Language, is a language for interacting with a Relational Database Management System (RDBMS). It is comprised of two major parts

  • Data definition language — commands and syntax used to define or reflect the structure of a dataset
  • Data query language — commands and syntax used to insert, edit, manipulate, and retrieve stored data

SQL is a standard, not a specific piece of technology. In practice, SQL only exists in specific implementations such as MySQL or PostgreSQL.

Who manages the standard for SQL?

SQL is a standard of the International Organization for Standardization (ISO).

What are the alternatives to SQL?

There are two different sets of alternatives to SQL.

On the one hand there are alternatives languages for use in a relational database system. There are a handful of such language alternatives used in specialized settings, but none which have the kind of generalized adoption that SQL enjoys.

On the other hand are alternative to the relational model of database design — that is, non-relational databases, which are sometimes called "NoSQL" databases. There are a number of very popular non-relational database systems, including CouchDB and Mongo.

Which SQL database implementation should I use or learn how to use?

If you are working with and writing apps (or planning to write apps) in PHP, you should start with MySQL. You might also want to look into MariaDB.

Web apps in all other languages — such as Ruby or Python — tend to use PostgreSQL.

SQLite is often used as in-app storage for mobile apps. Ruby on Rails also uses SQLite as its default built-in database, but most production apps written in Rails use PostgreSQL.

Oracle is the leading database for Enterprise (large organization) applications.