This repository is a comprehensive collection of SQL commands, covering fundamental to advanced SQL syntax and examples. Each command is illustrated with practical examples and explanations to build a solid understanding of SQL.
- Purpose: To serve as a quick reference and learning resource for SQL commands.
- Audience: Suitable for anyone learning SQL, from beginners to advanced users.
- Content: Contains syntax, examples, and explanations for each SQL command category.
- Data Retrieval (SELECT Statements)
- SELECT: Retrieves data from one or more tables.
- WHERE: Filters rows based on conditions.
- ORDER BY: Sorts the result set.
- LIMIT/OFFSET: Limits the number of rows returned.
- DISTINCT: Eliminates duplicate rows.
- Aggregate Functions
- COUNT(): Counts the number of rows.
- SUM(): Calculates the sum of values.
- AVG(): Calculates the average of values.
- MIN() and MAX(): Returns the minimum and maximum values.
- GROUP BY: Groups rows based on columns.
- HAVING: Filters groups based on aggregate conditions.
- Table Joins
- INNER JOIN: Selects records with matching values in both tables.
- LEFT JOIN (LEFT OUTER JOIN): Selects all records from the left table and matched records from the right.
- RIGHT JOIN (RIGHT OUTER JOIN): Selects all records from the right table and matched records from the left.
- FULL JOIN (FULL OUTER JOIN): Selects all records when there is a match in either left or right table.
- CROSS JOIN: Produces a Cartesian product of the two tables.
- SELF JOIN: Joins a table with itself.
- Data Manipulation Language (DML)
- INSERT INTO: Inserts new rows into a table.
- UPDATE: Modifies existing rows in a table.
- DELETE: Deletes rows from a table.
- TRUNCATE: Removes all rows from a table without logging each row.
- Data Definition Language (DDL)
- CREATE TABLE: Creates a new table.
- ALTER TABLE: Modifies an existing table.
- DROP TABLE: Deletes a table and its data.
- RENAME TABLE: Changes the name of a table.
- Constraints: PRIMARY KEY, FOREIGN KEY, UNIQUE, NOT NULL, CHECK
- Data Control Language (DCL)
- GRANT: Gives specific permissions to users.
- REVOKE: Removes specific permissions from users.
- Transaction Control Language (TCL)
- BEGIN/START TRANSACTION: Begins a transaction.
- COMMIT: Saves the transaction changes.
- ROLLBACK: Reverts changes since the last commit.
- SAVEPOINT: Sets a savepoint within a transaction.
- Clone the repository to your local machine:
https://github.com/ankan24/SQL-A2Z.git
-
Open any .sql file in your preferred SQL client or editor.
-
Run and test each command example to gain hands-on experience with SQL.