Show Menu
Cheatography
This is a draft cheat sheet. It is a work in progress and is not finished yet.

Important Commands

SELECT - gets data from a database
UPDATE - updates data in a database
DELETE - deletes data from a database
INSERT INTO - inserts new data into a database
CREATE DATABASE - creates a new database
ALTER DATABASE - modifies a database
CREATE TABLE - creates a new column in a database
ALTER TABLE - modifies a column
DROP TABLE - deletes a table
CREATE INDEX - creates an index (search key)
DROP INDEX - deletes an index

Statements

SELECT * FROM Customers; - select all records and fieldsin Customers
SELECT column1, column 2, .... FROM table_name WHERE condition;
SELECT DISTINCT column1, column2 ... FROM table_­name; - returns different values
SELECT COUNT(­DIS­TINCT Country) FROM Customers; - lists number of different values
   

Operators

= Equal
> Greater than
< less than
>= greater than or equal
<= less than or equal
<> Not eqal
BETWEEN - between a certain range
LIKE - search for a pattern
IN - to specify multiple possible values for a column