Labs ICT
⭐ Pro Login

Introduction to SQL

The language that talks to databases.

The Language of Databases

SQL (Structured Query Language) is the standard language for interacting with relational databases. You use SQL to create tables, insert data, query data, update records, and manage permissions. It's been around since the 1970s and remains the most widely used database language in the world.

SQL Sub-Languages


  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚                    SQL                           β”‚
  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
  β”‚   DDL    β”‚   DML    β”‚   DQL    β”‚      DCL       β”‚
  β”‚ Data     β”‚ Data     β”‚ Data     β”‚ Data Control   β”‚
  β”‚ Definitionβ”‚Manipulationβ”‚Query   β”‚                β”‚
  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
  β”‚ CREATE   β”‚ INSERT   β”‚ SELECT   β”‚ GRANT          β”‚
  β”‚ ALTER    β”‚ UPDATE   β”‚          β”‚ REVOKE         β”‚
  β”‚ DROP     β”‚ DELETE   β”‚          β”‚                β”‚
  β”‚ TRUNCATE β”‚ MERGE    β”‚          β”‚                β”‚
  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Your First Query


  -- Select all columns from the Students table
  SELECT * FROM Students;

  -- Select specific columns
  SELECT Name, Email FROM Students;

  -- Select with a condition
  SELECT Name, Age FROM Students WHERE Age > 22;

  -- Insert data
  INSERT INTO Students (ID, Name, Age, Email)
  VALUES (4, 'Diana', 24, 'diana@example.com');

  -- Update data
  UPDATE Students SET Age = 26 WHERE ID = 1;

  -- Delete data
  DELETE FROM Students WHERE ID = 4;

SQL Syntax Rules

  • SQL is case-insensitive for keywords (SELECT = select = Select).
  • Statements end with a semicolon (;).
  • String values use single quotes ('Alice').
  • Comments: -- single line or /* multi-line */.
  • Keywords cannot be used as identifiers (table/column names) without quoting.

πŸ§ͺ Quick Quiz

What does SQL stand for?