Sqlcheetsheet
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

Sqlcheetsheet

on

  • 430 views

 

Statistics

Views

Total Views
430
Views on SlideShare
429
Embed Views
1

Actions

Likes
0
Downloads
4
Comments
0

1 Embed 1

http://www.linkedin.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Sqlcheetsheet Document Transcript

  • 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