0% found this document useful (0 votes)
3 views2 pages

Essential SQL Commands Guide

Uploaded by

rg973369
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Essential SQL Commands Guide

Uploaded by

rg973369
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Complete SQL Commands – Presentable Guide

1. DDL (Data Definition Language)


Command Use
CREATE Creates new tables, databases, indexes, views.
ALTER Modifies existing table structure.
DROP Deletes a table, database, view, or index.
TRUNCATE Removes all rows but keeps table structure.
RENAME Changes name of the table.

2. DML (Data Manipulation Language)


INSERT Adds new records to tables.
UPDATE Modifies existing records.
DELETE Deletes specific records from tables.

3. DQL (Data Query Language)


SELECT Retrieves data from the database using conditions.

4. DCL (Data Control Language)


GRANT Gives privileges to users.
REVOKE Withdraws privileges from users.

5. TCL (Transaction Control Language)


COMMIT Saves the changes permanently.
ROLLBACK Undo changes since last COMMIT.
SAVEPOINT Creates a checkpoint inside a transaction.

6. Useful SQL Clauses


Clause Use
WHERE Filters data based on conditions.
ORDER BY Sorts data ascending/descending.
GROUP BY Groups rows with similar values.
HAVING Filters groups after GROUP BY.
DISTINCT Removes duplicate values.
LIKE Pattern matching using % and _.
BETWEEN Checks values within a range.
IN Matches any value in a list.

7. SQL Joins
Join Type Use
INNER JOIN Returns matching rows from both tables.
LEFT JOIN Returns all rows from left table + matches from right.
RIGHT JOIN Returns all rows from right table + matches from left.
FULL JOIN Returns all rows when there is a match in either table.
SELF JOIN Joins a table with itself.
CROSS JOIN Returns Cartesian product of two tables.

You might also like