100% found this document useful (2 votes)
837 views

SQL Cheatsheet

This document provides a cheatsheet of common SQL statements organized into the following sections: SQL SELECT statements, SQL operators, SQL JOIN statements, SQL table statements, SQL update statements, and SQL view statements. It summarizes key SQL keywords and syntax for tasks like selecting data, filtering with operators, joining tables, creating/modifying tables and indexes, and working with views. The cheatsheet acts as a quick reference guide for common SQL statements and concepts.

Uploaded by

mariamagda
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
837 views

SQL Cheatsheet

This document provides a cheatsheet of common SQL statements organized into the following sections: SQL SELECT statements, SQL operators, SQL JOIN statements, SQL table statements, SQL update statements, and SQL view statements. It summarizes key SQL keywords and syntax for tasks like selecting data, filtering with operators, joining tables, creating/modifying tables and indexes, and working with views. The cheatsheet acts as a quick reference guide for common SQL statements and concepts.

Uploaded by

mariamagda
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Copyright by SQLDatabaseTutorial.

com 2008
SQL CHEET SHEET
SQL SELECT STATEMENTS SQL OPERATORS SQL JOIN STATEMENTS
SELECT * FROM t SELECT * FROM t SELECT * FROM t1
WHERE c1 [NOT] BETWEEN v1 INNER JOIN t2 ON conditions
SELECT c1,c2 FROM t
AND v2
SELECT * FROM t
SELECT c1,c2 FROM t
SELECT * FROM t WHERE c1 [NOT ] IN (v1,v2,…)
WHERE conditions
WHERE c1 [NOT ] IN (v1,v2,…)
SELECT * FROM t1
SELECT c1,c2 FROM t
SELECT* FROM t INNER JOIN t2 ON conditions
WHERE conditions
WHERE c1 > v1 AND c1 < v2 WHERE conditions
ORDER BY c1 ASC,c2 DESC
SELECT * FROM t SELECT *
SELECT DISTICT c1,c2
WHERE c1 < v1 OR c1 > v2 FROM t1, t2
FROM t
WHERE conditions
SELECT * FROM t
SELECT c1, aggregate(c2 * c3)
WHERE c1 = v1 SELECT * FROM t1
FROM t
LEFT JOIN t2 ON conditions
GROUP BY c1 SELECT * FROM t
WHERE c1 <> v1 SELECT * FROM t1
SELECT c1, aggregate(c2 * c3)
RIGHT JOIN t2 ON conditions
FROM t
GROUP BY c1 SQL TABLE STATEMENTS SELECT * FROM t1
HAVING c1 > v1 CREATE TABLE t( FULL OUTER JOIN t2 ON conditions
c1 dt1(l1), SELECT * FROM t1 AS at1
SQL UPDATE DATABASE c2 dt2(l2), INNER JOIN t2 AS at2 ON at1.c1 =
... at2.c2
INSERT INTO t (c1,c2…)
)
VALUES (v1,v2…)
DROP TABLE t SQL VIEW STATEMENTS
INSERT INTO t1 (c1,c2…)
SELECT c1,c2… FROM t2 ALTER TABLE t CREATE VIEW vw
WHERE conditions ADD COLUMN c dt(l) AS
SELECT c1,c2
UPDATE t ALTER TABLE t
FROM t
SET c1 = v1, c2 = v2,… DROP COLUMN c
WHERE conditions ALTER VIEW vw
AS
DELETE FROM t SQL VIEW STATEMENTS SELECT c1,c2
WHERE conditions CREATE UNIQUE FROM t
TRUNCATE TABLE t INDEX idx ON t(c1,c2..)
DROP VIEW vw
DROP INDEX t.idx

t:table name, c: column name,vw: view name, v: value,dt: data type,l: data type length, at: table alias,aggregate: aggreate
function,idx: index name

You might also like