← Back to Lessons
BEGINNER ⏱ 20 minutes

What is SQL?

SQL (Structured Query Language) is the standard language for managing and manipulating data in relational databases. Whether you're a data analyst, web developer, or business professional, SQL is an essential skill for working with data.


What Does SQL Stand For?

💡 Fun Fact

SQL was originally developed at IBM in the early 1970s and was called SEQUEL (Structured English Query Language). The name was later shortened to SQL, but many people still pronounce it as "sequel" while others say "S-Q-L". Both pronunciations are correct!

What Can SQL Do?

SQL is incredibly powerful and versatile. Here's what you can accomplish with SQL:

SQL is a Standard Language

Although SQL is an ANSI (American National Standards Institute) and ISO (International Organization for Standardization) standard, there are different versions and dialects of SQL used by different database systems:

MySQL

Popular open-source database, used by WordPress, Facebook

PostgreSQL

Advanced open-source database with robust features

Oracle

Enterprise-grade database for large organizations

Microsoft SQL Server

Microsoft's relational database management system

Good news: The core SQL commands (SELECT, INSERT, UPDATE, DELETE) are the same across all these systems! Once you learn the fundamentals, you can work with any SQL database.

Understanding SQL Statements

SQL consists of statements - commands that tell the database what you want to do. Every SQL statement starts with a keyword (like SELECT, INSERT, UPDATE) and ends with a semicolon (;).

The Semicolon (;) - Statement Terminator

The semicolon is used to separate SQL statements. It tells the database "this statement is complete, execute it now." Think of it like a period at the end of a sentence.

-- Correct: Statement ends with semicolon
SELECT * FROM students;

-- Also correct: Multiple statements
SELECT * FROM students;
SELECT * FROM courses;

-- Incorrect: Missing semicolon
SELECT * FROM students

⚠️ Important Note

Some database systems don't require the semicolon for single statements, but it's considered best practice to always include it. This ensures your SQL works across all systems and makes it easier to write multiple statements.

SQL Keywords and Commands

SQL uses special keywords to perform different operations. Here are the most important ones you'll learn:

1. Data Query Language (DQL)

SELECT - Retrieve data from database

2. Data Manipulation Language (DML)

INSERT - Add new data
UPDATE - Modify existing data
DELETE - Remove data

3. Data Definition Language (DDL)

CREATE - Create new database objects (tables, databases)
ALTER  - Modify existing database objects
DROP   - Delete database objects

4. Data Control Language (DCL)

GRANT  - Give user access permissions
REVOKE - Remove user access permissions

5. Transaction Control Language (TCL)

COMMIT   - Save changes permanently
ROLLBACK - Undo changes since last COMMIT
SAVEPOINT - Set a point to rollback to

TCL commands manage transactions in databases. A transaction is a set of SQL operations that are treated as a single unit. If something goes wrong, you can use ROLLBACK to undo all changes. When everything is correct, use COMMIT to save the changes permanently.

SQL is NOT Case Sensitive

SQL keywords are not case-sensitive. This means SELECT, select, and Select all work the same way. However, there are conventions that make code more readable:

-- All of these work the same:
SELECT * FROM students;
select * from students;
Select * From Students;

-- Best practice: Keywords in UPPERCASE
SELECT * FROM students;

👍 Best Practice

Most SQL developers write keywords in UPPERCASE and table/column names in lowercase. This makes queries easier to read and understand at a glance.

Your First SQL Query

Let's write your first SQL statement! This simple query retrieves all data from a table called "students":

SELECT * FROM students;

Let's break down what each part means:

Comments in SQL

Comments are notes in your code that the database ignores. They help you and others understand what your SQL does.

Single-Line Comments

-- This is a single-line comment
SELECT * FROM students; -- Get all students

Multi-Line Comments

/* This is a multi-line comment.
   It can span multiple lines.
   Useful for longer explanations. */
SELECT * FROM students;

Why Learn SQL?

💼 Career Opportunities

SQL skills are in high demand. Data analysts, business analysts, developers, and data scientists all use SQL daily.

📊 Make Data-Driven Decisions

Extract insights from data, create reports, and answer business questions without relying on others.

🚀 Universal Skill

SQL works with almost every database system. Learn it once, use it everywhere.

Real-World SQL Use Cases

Key Takeaways

  • ✅ SQL stands for Structured Query Language
  • ✅ SQL is used to communicate with databases
  • ✅ All SQL statements end with a semicolon (;)
  • ✅ SQL keywords are NOT case-sensitive (but UPPERCASE is convention)
  • ✅ SQL is a standard language that works across different database systems
  • ✅ Comments help document your code (-- for single line, /* */ for multi-line)
  • ✅ The five main types of SQL commands are: DQL, DML, DDL, DCL, and TCL

What's Next?

Now that you understand what SQL is and how statements work, you're ready to start writing queries! In the next lesson, you'll learn about the SELECT statement - the most fundamental and frequently used SQL command.

💪 Ready to Practice? Head over to our practice environment and try your first SQL query. Type SELECT * FROM students; and see what happens!

← Back to Lessons
Next: SELECT Basics →