jump to main content

SQL Quick Reference Guide

Statements

SELECT [ DISTINCT ] * | LIST OF COLUMNS, FUNCTIONS, CONSTANTS
   FROM LIST OF TABLES OR VIEWS
   [ WHERE CONDITION(S) ]
   [ ORDER BY ORDERING COLUMN(S) [ ASC | DESC ] ]
   [ GROUP BY GROUPING COLUMN(S) ]
   [ HAVING CONDITION(S) ]

DELETE FROM TABLE NAME
   [ WHERE CONDITION(S) ]

INSERT INTO TABLE NAME
   [ (COLUMN LIST) ]
   VALUES (VALUE LIST)

UPDATE TABLE NAME
   SET COLUMN NAME = VALUE
   [ WHERE CONDITION ]

Functions

Function Purpose
SUM Total of the values in a field.
AVG Average of the values in a field.
MIN Lowest value in a field.
MAX Highest value in a field.
COUNT Number of values in a field, not counting Null (blank) values.

Predicates

Predicate Description
BETWEEN ... AND Compares a value to a range formed by two values.
IN Determines whether a value exists in a list of values or a table.
LIKE Compares, in part or in whole, one value with another.
JOIN Joins two tables.

Data Definition

CREATE TABLE TABLE_NAME
   ( COLUMN_NAME DATA_TYPE [(SIZE)] COLUMN_CONSTRAINT,
   [, other column definitions,...]
   [, primary key constraint]
   )

ALTER TABLE TABLE_NAME ADD | DROP | MODIFY
   ( COLUMN_NAME DATA_TYPE [(SIZE)] COLUMN_CONSTRAINT,
   [, other column definitions,...]
   )

DROP TABLE TABLE_NAME

CREATE [UNIQUE] [ASC | DESC] INDEX INDEX_NAME
   ON TABLE_NAME ( COLUMN_LIST )

DROP INDEX INDEX_NAME ON TABLE_NAME

CREATE VIEW VIEW_NAME AS QUERY_NAME

CONSTRAINT CONSTRAINT_NAME
    {PRIMARY KEY | UNIQUE | NOT NULL |
    REFERENCES FOREIGN_TABLE [(FIELD_LIST)]}


| Basic Structure | Multimedia | Links | Lists | Frames |
| Tables | Forms | Style Sheets | General Formatting |
| Color Names | Color Codes | Color Tester |
| ASCII Codes | Entities | META Tags |
| SQL Reference | Web Graphics |

Free-CGI.com is updated on a daily basis. New features and applications are added almost
every day. Free-CGI.com is always under construction. If you have any comments or
suggestions, please contact free-cgi. Thanks!

Donate $1 (or more) to Free-CGI
Thanks!

Copyright © 1995 - 2017 Free CGI. All rights reserved.

web
analytics