What Is SQL?
Table of Contents
SQL (Structured Query Language) is the standard language for working with relational databases. You use it to define tables, read data, insert records, update records, and delete records. It's everywhere in backend development and data analysis because it handles repeatable queries over large datasets without spreadsheet busywork.
All the content from our Boot.dev courses is available for free here on the blog. This one is the "Introduction" chapter of Learn SQL. If you want to try the far more immersive version of the course, do check it out!
Click to play video
What Is SQL Used For?
Structured Query Language, or SQL (pronounced "squeel" by the in-crowd), is the primary programming language used to manage and interact with relational databases. A relational database organizes data into tables made of rows and columns. It can also define relationships between those tables, such as the connection between a customer and their orders.
SQL is a standardized language, and it can perform operations like creating, updating, reading, and deleting records within a database. These four basic data operations are often called CRUD. SQL also defines database structures, enforces data rules, joins related tables, groups records, and calculates totals and averages. If you plan to work in backend web development, SQL is one of the most useful database skills you can learn.
Generally speaking, SQL is extremely powerful and programmable. While spreadsheets are great for simple manual data manipulation, SQL is designed for automated and scalable data operations. It can handle large datasets, complex queries, and integrate easily with general purpose programming languages like Python, TypeScript, and Go.
SQL is also a declarative language. You describe the result you want, and the database decides how to retrieve it. For example, you can ask for every unpaid invoice without writing the low-level procedure that scans indexes, loads pages from disk, and filters rows.
Data Organization in a SQL Database
A database table looks a bit like a spreadsheet. Each column describes one attribute, and each row represents one record.
Here's a small users table:
| id | name | age | balance | is_admin |
|---|---|---|---|---|
| 1 | John Smith | 28 | 450.00 | true |
| 2 | Darren Walker | 27 | 200.00 | true |
| 3 | Jane Morris | 33 | 496.24 | false |
Unlike a loose spreadsheet, a relational database can apply a schema: definitions and constraints that control which columns exist and which values they accept. You define those columns with statements such as CREATE TABLE. Type rules vary by database, though. PostgreSQL has a rich type system, while SQLite uses dynamic typing by default (it also supports stricter tables). Like Python and JavaScript, SQLite has a loose type system... You can store any type of data in any field, regardless of how you defined it. Remember: just because you can do something, doesn't mean you should!
Another way in which SQLite is a bit different is that it stores Boolean values as integers – the integers 0 and 1:
0=false1=true
Production systems also need indexes, transactions, and a safe process for database migrations, which change a schema without throwing existing data into a wood chipper.
A Basic SQL Query
The SELECT statement reads data. To return every column and row from users, use the * wildcard:
SELECT * FROM users;
To return only one column, replace * with its name:
SELECT name FROM users;
Separate multiple column names with commas:
SELECT name, age, balance FROM users;
The result contains those columns in the requested order. Add a WHERE clause to filter rows, ORDER BY to sort them, or LIMIT to cap the number returned.
SQL examples conventionally end with a semicolon. It terminates the statement, and some clients won't run the query until they see it. SQL keywords are usually uppercase for readability, though most database systems treat them as case-insensitive.
Learning to write SQL directly is useful even if your application uses an object-relational mapper. Abstractions leak, and you still need SQL to understand generated queries, investigate performance, and fix production data. That's why backend developers need SQL.
Databases That Use SQL
SQL is just a query language. You typically use it to interact with a specific database technology. For example:
Although many different databases use the SQL language, most of them will have their own dialect. It's critical to understand that not all databases are created equal. Just because one SQL-compatible database does things a certain way, doesn't mean every SQL-compatible database will follow those exact same patterns. Each database defines specific rules, practices, and strategies that separate them from their competitors, so check the documentation for the database you're using.
Personally, SQLite and PostgreSQL are my favorites from the list above. Postgres is a very powerful, open-source, production-ready SQL database. SQLite is a lightweight, embeddable, open-source database. I usually choose one of these technologies if I'm doing SQL work.
SQLite is a serverless database management system (DBMS) that has the ability to run within applications, whereas PostgreSQL uses a client-server model and requires a server to be installed and listening on a network, similar to an HTTP server. SQLite is great for embedded projects, web browsers, and toy projects. It's lightweight, but has limited functionality compared to the likes of PostgreSQL or MySQL – two of the more common production SQL technologies. For most backend web servers, PostgreSQL is a more production-ready option, but SQLite is great for learning and for small systems.
MySQL, SQL Server, and Oracle are also widely used. Pick based on your deployment, workload, team, and existing infrastructure, not syntax alone. Our list of backend technologies has more context on the common options.
SQL vs. NoSQL Databases
Click to play video
When talking about SQL databases, we also have to mention the elephant in the room: NoSQL.
To put it simply, a NoSQL database is a database that does not use SQL (Structured Query Language). Each NoSQL database system typically has its own way of writing and executing queries. For example, MongoDB uses MQL (MongoDB Query Language), and ElasticSearch simply has a JSON API.
While most relational databases are fairly similar, NoSQL databases tend to be fairly unique and are used for more niche purposes. Some of the main differences between SQL and NoSQL databases are:
- NoSQL databases are usually non-relational; SQL databases are usually relational.
- SQL databases usually have a defined schema; NoSQL databases usually have a dynamic schema.
- SQL databases are table-based; NoSQL databases have a variety of different storage methods, such as document, key-value, graph, wide-column, and more.
A few of the most popular NoSQL databases are:
- MongoDB, which stores document-like records
- Cassandra, which uses a distributed wide-column model
- CouchDB
- DynamoDB
- ElasticSearch
- Redis, which provides specialized in-memory data structures
That said, the boundaries aren't absolute. Some relational databases support JSON documents, and some NoSQL databases support schemas, transactions, or SQL-like query languages. "SQL has schemas and NoSQL doesn't" is a convenient beginner shortcut, but it isn't a reliable technical rule.
Choose based on how your application reads and writes data and which guarantees it needs. Relational databases are a practical default when data has clear relationships, transactions matter, and queries vary. A NoSQL system fits when its model solves a specific problem, such as storing a graph of social connections or serving a low-latency key-value cache.
If you're learning backend development, start with relational design and SQL. Once those foundations are clear, explore other database models when a project's requirements call for them.
Frequently Asked Questions
What does SQL stand for?
SQL stands for Structured Query Language. It is the standard language used to define, query, and modify data in relational databases.
What is SQL used for?
SQL is used to create database structures and to read, insert, update, and delete data. It can also join tables, group records, enforce constraints, and manage transactions.
Is SQL a programming language?
SQL is a domain-specific programming language for relational data. It is declarative, so you describe the result you want rather than the exact steps used to produce it.
What is the difference between SQL and MySQL?
SQL is a language. MySQL is a database management system that implements SQL along with its own features and dialect.
Should beginners learn SQL or NoSQL first?
Most backend beginners should learn SQL first. Relational databases are widely used, and SQL teaches durable concepts such as tables, relationships, constraints, transactions, and structured queries.
