SQL Documentation

Introduction

SQL (Structured Query Language) is a standard language for managing and manipulating data in relational database management systems (RDBMS). It allows you to define, manipulate, and control access to data structured in tables.

Different types of SQL include: SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, and INDEX.

Key Concepts

Key Concepts:

SQL Commands - SELECT

The SELECT statement retrieves data from one or more tables. The SQL Wiki provides details on the different options.

Example: SELECT * FROM Customers;

SQL Commands - INSERT

The INSERT statement inserts new data into a table. It requires a 'values' clause to specify the data to insert.

Example: INSERT INTO Customers (Name, City) VALUES ('Alice', 'New York');

SQL Commands - UPDATE

The UPDATE statement modifies existing data in a table. It requires a 'values' clause to specify the data to update.

Example: UPDATE Customers SET City = 'London' WHERE CustomerID = 1;

SQL Commands - DELETE

The DELETE statement removes data from a table. It requires a 'WHERE' clause to specify the rows to delete.

Example: DELETE FROM Customers WHERE CustomerID = 1;

SQL Commands - CREATE

The CREATE statement creates new tables in a database. It requires the table name and columns to be specified.

Example: CREATE TABLE Customers (CustomerID INT PRIMARY KEY, Name VARCHAR(255), City VARCHAR(255));

SQL Commands - ALTER

The ALTER statement modifies the structure of an existing table. It requires the table name and the attributes to modify.

Example: ALTER TABLE Customers ADD Email VARCHAR(255);

SQL Commands - DROP

The DROP statement deletes a table. It requires the table name.

Example: DROP TABLE Customers;

SQL Commands - INDEX

The INDEX statement creates indexes on columns to speed up query performance.

Example: CREATE INDEX idx_Name ON Customers (Name);

SQL Commands - JOIN

The JOIN statement combines rows from two or more tables based on related columns.

Example: JOIN Customers ON Customers.CustomerID = Orders.CustomerID;