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

SQL Command Cheatsheet

This document is a SQL command cheatsheet that provides essential commands for creating, inserting, updating, deleting, and altering tables. It also includes commands for filtering, ordering, aggregating data, and pattern matching. Each command is presented in a concise format for quick reference.

Uploaded by

LOL
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)
2 views2 pages

SQL Command Cheatsheet

This document is a SQL command cheatsheet that provides essential commands for creating, inserting, updating, deleting, and altering tables. It also includes commands for filtering, ordering, aggregating data, and pattern matching. Each command is presented in a concise format for quick reference.

Uploaded by

LOL
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
You are on page 1/ 2

SQL Command Cheatsheet

Create Table:
CREATE TABLE table_name (...);

Insert:
INSERT INTO table_name VALUES (...);

Update:
UPDATE table_name SET column = value WHERE ...;

Delete:
DELETE FROM table_name WHERE ...;

Drop:
DROP TABLE table_name;

DROP DATABASE db_name;

Alter (Add Column):


ALTER TABLE table_name ADD column_name datatype;

Alter (Drop Column):


ALTER TABLE table_name DROP COLUMN column_name;

Rename Table:
RENAME TABLE old_name TO new_name;

Filter (WHERE):
SELECT * FROM table_name WHERE condition;

Membership (IN/NOT IN):


SELECT * FROM table_name WHERE column IN (...);

Order By:
SELECT * FROM table_name ORDER BY column [ASC|DESC];

Aggregate (SUM):
SELECT SUM(column) FROM table_name;

Aggregate (COUNT):
SELECT COUNT(*) FROM table_name;
Aggregate (AVG):
SELECT AVG(column) FROM table_name;

Group By:
SELECT column, COUNT(*) FROM table GROUP BY column;

Pattern Matching:
SELECT * FROM table WHERE column LIKE 'A%';

You might also like