Oracle Variable – DEF, UNDEF, ACCEPT, COLUMN

A reference post. See the syntax for various commands
| DEF variablename=value | Define variable variablename, if not already defined, and set its value to value |
| DEF variablename | Show the value and type of variablename |
| DEF | Show the value and type of all currently defined variables |
| UNDEF variablename | Undefine variablename |
| ACCEPT variablename [type] [FORMAT format] [DEFAULT defaultvalue] [PROMPT prompt_text | NOPROMPT] | Define variablename, if not already defined, and read a line of input into it. Prompt user for that input with prompt_text, if supplied, and check the user’s input againt FORMAT if supplied. |
| COLUMN columnname [ NEW_VALUE variablename | OLD_VALUE variablename ] | When a query with a column named columnname in its resultset is run, defines variablename and puts the column value in variablename |
| CLEAR COLUMNS | Clears formatting and NEW_VALUE / OLD_VALUE on columns. Does not undefine any variables. |