Last active
May 1, 2020 08:38
-
-
Save thibaultlaurens/4586266 to your computer and use it in GitHub Desktop.
Oxford Brookes MSc - SQL cheatsheet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* CREATE TABLE table_name (attribute1 type, ... , attributeN type) | |
* Types: char(n), varchar(n), int, smallint, real, DATE, TIME, DATETIME | |
* INSERT INTO table_name VALUES ( ... ) | |
* DROP TABLE table_name | |
* ALTER TABLE table_name ADD COLUMN new_column type | |
ALTER TABLE table_name DROP COLUMN column type | |
* DELETE FROM table_name WHERE some_column = some_value | |
* id integer primary key autoincrement | |
foreign key (primary key) references pk_table_name | |
* SELECT aatribute_name_list | |
FROM table_name | |
WHERE condition | |
* LIKE letters, _, % | |
* Duplicates: DISTINCT, UNION, INTERSECTION, EXCEPT | |
* ORDER BY and GROUP BY | |
* Aggregates: min, max, count, sum, avg, distinct | |
* HAVING, NATURAL JOIN, JOIN ON | |
* SUMMARY: | |
SELECT [DISTINCT] target_list | |
FROM table_name [, table_name] * | |
[WHERE predicate] | |
[GROUP BY attribute_name] [, attribute_name] * | |
[HAVING function_list] | |
[ORDER BY attribute_name [DESC] [, attribute_name [DESC]]] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment