Sqlcheetsheet

445 views

Published on

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
445
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
9
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Sqlcheetsheet

  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

×