SQL Cheatsheet
SQL Cheatsheet
@yosracodes
I T, I T, CI ,
, C , C
IT, IT
T , TI , TI
TO DISK = ‘<PATH>’
Cross Product (,)
used to produce a result table that has the number of
rows of the first table multiplied by the number of
Insert used to insert new tuples
(rows) in a table
rows of the second table
SELECT <ATTRIBUTE LIST>
*you do not need to specify all columns if you will add values
for all the columns Duplicates
Delete used to delete tuples (rows)
from a table
DISTINCT is used to eliminate duplicate
ALL is used to allow duplicates
DELETE FROM <TABLE NAME>
WHERE <CONDITION>
FROM <TABLE NAME>
*if you don’t add the WHERE clause all rows will be deleted
,
SELECT DISTINCT <ATTRIBUTE LIST>
String Comparisons
WHERE <CONDITION> I E is used for string compariso
L K
ANY and ALL can be used with (=, >, >=, <, <=, <>) to
compare a value with a set
SELECT <ATTRIBUTE LIST>
V
WHERE < ALUE> IN <ANOTHER SELECT QUERY>
SELECT <ATTRIBUTE LIST>
value is NULL V
WHERE < ALUE> > ALL / ANY <ANOTHER SELECT QUERY>
Types of Join
ON <JOIN CONDITION>
Assertion I nner Join Left Join Right Join Full Outer Join
colum
CHECK (<CONDITION>)
SUM - adds together all the values in a particular
colum
Trigger MIN - returns the minumum value in a colum
BEFORE / AFTE R
ON <TABLE NAME>
FOR EACH RO W
<TRIGGER BODY>