├── LICENSE └── README.md /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Unofficial Oracle Database Documentation 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SQLcl 2 | 3 | * [Intro](#intro) 4 | * [Commands](#commands) 5 | * [Scripting](#scripting) 6 | * Advanced usage 7 | 8 | ## Intro 9 | 10 | What is SQLcl? From their own web portal: 11 | 12 | > Oracle SQLcl is a free command line interface for Oracle Database. It allows you to interactively or batch execute it's own commands alongside with SQL, PL/SQL, operating system commands, and JavaScript. SQLcl offers a feature-rich experience in a shell environment, while also supporting all of the previous scripts our customers have developed for their Oracle environments.. 13 | 14 | Whilst SQL*Plus is still around, no new features have been added in a while. SQLcl aims to bridge the divide. The purpose of this project is to provide some high level documentation in lieu of any current official documentation - currently, there is a lot of content out there - but most of it is located in blog posts, so this should provide a single point of reference. 15 | 16 | New commands that have been made available can be identified with the help command. Any new commands (new, as in, not available in SQL*Plus) will be styled with bold and underline when running the `help` command. They currently include: 17 | 18 | * ALIAS 19 | * APEX 20 | * BRIDGE 21 | * CD 22 | * CTAS 23 | * [DDL](#ddl) 24 | * FORMAT 25 | * HISTORY 26 | * INFORMATION 27 | * LOAD 28 | * NET 29 | * NOHISTORY 30 | * OERR 31 | * REPEAT 32 | * REST 33 | * SCRIPT 34 | * SODA 35 | * SSHTUNNEL 36 | * TNSPING 37 | 38 | You can get more help on each command by typing `help `, which will provide a basic overview of the command. 39 | 40 | One of the great new features is the ability to run SQLcl commands through a script. Typically, the scripting language would be JavaScript - but SQLcl is Java based, so any language that can be run in Java will be supported. 41 | 42 | ## Commands 43 | 44 | ### DDL 45 | 46 | DDL can be used to pull the DDL for any database object that is available to the connected user. The syntax is `DDL [ [] [SAVE ]]` 47 | 48 | So, as a basic example - if we connect to `HR` we can generate the DDL for our employees table with `DDL employees`. We could additionally specify it's a table: `DDL employees table`. Or if we want to save it to a file (avoiding spools), `DDL employees save emp.sql`. 49 | 50 | If you run this as is, you will notice that all the storage options are included. This is all configurable. If you run the command `ddl options` you will see what's available to be set: 51 | 52 | ```sql 53 | SQL> show ddl 54 | STORAGE : ON 55 | INHERIT : ON 56 | SQLTERMINATOR : ON 57 | OID : ON 58 | SPECIFICATION : ON 59 | TABLESPACE : ON 60 | SIZE_BYTE_KEYWORD : ON 61 | PRETTY : ON 62 | REF_CONSTRAINTS : ON 63 | FORCE : ON 64 | PARTITIONING : ON 65 | CONSTRAINTS : ON 66 | INSERT : ON 67 | BODY : ON 68 | CONSTRAINTS_AS_ALTER : ON 69 | SEGMENT_ATTRIBUTES : ON 70 | ``` 71 | 72 | So, we can turn any of these options off with: `set ddl