Skip to content

Latest commit

 

History

History
46 lines (35 loc) · 1.48 KB

File metadata and controls

46 lines (35 loc) · 1.48 KB

SQL stands for Structured Query Language. It’s a special programming language used to manage and interact with relational databases. In simple terms, it allows you to store, retrieve, update, and delete data in databases.

Here’s a breakdown:

  1. Databases and Tables

    • A database is like a digital filing cabinet.
    • Inside a database, information is stored in tables, which are like spreadsheets with rows (records) and columns (fields).
  2. Core Functions of SQL SQL is mainly used for four things, often called CRUD operations:

    • CCreate: Add new data or tables (INSERT)
    • RRead: Retrieve data (SELECT)
    • UUpdate: Modify existing data (UPDATE)
    • DDelete: Remove data (DELETE)
  3. Other Uses SQL can also:

    • Define database structure (CREATE TABLE, ALTER TABLE)
    • Control access to data (GRANT, REVOKE)
    • Query multiple tables together (JOIN)
    • Perform calculations and filtering (WHERE, GROUP BY, ORDER BY)

Example:

-- Create a table
CREATE TABLE Students (
    ID INT PRIMARY KEY,
    Name VARCHAR(50),
    Age INT
);

-- Insert data
INSERT INTO Students (ID, Name, Age) VALUES (1, 'Alice', 16);

-- Retrieve data
SELECT * FROM Students;

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

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

Think of SQL as the language you speak to a database to tell it what you want it to do.