SQL Cheatsheet: Icbc Road Test
SQL Cheatsheet: Icbc Road Test
KEY
---
Curly braces group alternatives together,
and alternatives are separated by pipes: {this | that | t'other}
Clauses in brackets are optional: You [and john] can come.
An asterisk indicates 0 or more instances: I like to eat[ and eat]*.
A plus-sign indicates 1 or more instances: Run fast,[ go]+!
A plus-sign also indicates addition: select (1 + 3) from dual;
FUNDAMENTALS
------------
<name> : [a-zA-Z][a-zA-Z0-9_]* - that is, a string of alphanumeric chars
and underscores starting with an alpha
char.
<number> : [0-9]+
<datatype>: {integer | char(<number>) | varchar2(<number>) | date}
LITERALS
--------
<value> : {<number> | <string> | <number-expr> | <string-expr>}
<values> : ( <value> [, <value>]* )
<number-expr>: {<number> | <column-name>} + [<number> | <column-name>]*
<string-expr>: {<string> | <column-name>} || [<string> | <column-name>]*
CREATION
--------
<create-table-new> : create table <name> ( <new-columns> )
<create-table-from>: create table <name> as <select>
PL-SQL BASICS
-------------
<var-name> : A variable passed into a function, or definied in <declarations>
<argument> : <name> IN <datatype>
<arguments>: <argument> [, <argument>]*
<args> : <value> [, <value>]*
PL-SQL
------
<create-function>: create or replace function <name> ( <arguments> )
return <datatype> AS [<declarations>] BEGIN <function-body> END;