SQL Practice
Back to Learning Center

SQL Basics

Learn the fundamental concepts of SQL to get started with database querying

What is SQL?
Understanding the basics of Structured Query Language

SQL (Structured Query Language) is a standardized programming language designed for managing and manipulating relational databases. It allows you to perform tasks such as:

  • Querying data from databases
  • Inserting, updating, and deleting records
  • Creating and modifying database structures
  • Setting permissions and access controls

SQL is used by many database systems including MySQL, PostgreSQL, Oracle, SQL Server, and SQLite.

Basic SQL Syntax
Understanding the structure of SQL statements

SQL statements typically follow this pattern:

SELECT column1, column2, ...
FROM table_name
WHERE condition
ORDER BY column_name;

Key points to remember:

  • SQL keywords are case-insensitive (SELECT is the same as select)
  • Statements typically end with a semicolon (;)
  • Whitespace and line breaks are ignored
  • Comments start with -- for single line or /* */ for multi-line
Core SQL Statements
The fundamental operations you can perform with SQL

SELECT

Retrieves data from one or more tables:

SELECT first_name, last_name FROM employees;

Use SELECT * to retrieve all columns.

INSERT

Adds new records to a table:

INSERT INTO employees (first_name, last_name, department)
VALUES ('John', 'Doe', 'Marketing');

UPDATE

Modifies existing records:

UPDATE employees
SET salary = 75000
WHERE employee_id = 123;

DELETE

Removes records from a table:

DELETE FROM employees
WHERE employee_id = 123;

Warning: Always use WHERE clause to avoid deleting all records!