Presentation is loading. Please wait.

Presentation is loading. Please wait.

SQLcl: A Modern Command Line Interface to the Oracle Database

Similar presentations


Presentation on theme: "SQLcl: A Modern Command Line Interface to the Oracle Database"— Presentation transcript:

1 SQLcl: A Modern Command Line Interface to the Oracle Database
Galo Balda September 18, 2016

2

3 About Me Austin, TX Ecuador

4 Agenda What is it? Getting started: JRE, download, install, connect
Show it! Multi-line Editing TAB Completion Result Formatting New Commands: History, Information, DDL, CTAS, Alias, Load, Script

5 What is it? A command line interface for Oracle Database that combines the power of SQL*Plus and SQL Developer Takes helpful GUI functionality to the CLI: Object name/Command completion, SQL/Command execution history and recall, query result formatting, user friendly text editing, etc… It allows you to interactively or batch execute its own commands alongside with SQL, PL/SQL, operating system commands, and JavaScript

6 How do I get started? SQLcl: Release requires JRE 1.8.0_50 or higher Copying a specific JRE install to SQLCL_HOME\bin forces to use that JRE

7 How do I get started? Get the .ZIP from OTN Unzip it
No installer or setup

8 How do I get started? Start a terminal/cmd session
Run the SQL program in SQLCL_HOME/bin No need for the Oracle client

9 Connecting to the Database
TNS: hr/oracle looks at the $TWO_TASK, $ORACLE_HOME, $TNS_ADMIN environment variables EZConnect: LDAP SSH Tunnel Wallet

10 I’m in, where’s the good stuff?
Supported commands available from the HELP command New commands are highlighted

11 I’m in, where’s the good stuff?
HELP <command> prints the command’s description and examples Help topics also available for system variables

12 Multi-line editing No need to jump to an external editor
Use the arrow keys to move through your query The EDIT command is still available

13 Multi-line editing Ctrl-a Advance to beginning of current line
Ctrl-e Advance to end of current line Ctrl-w Advance to beginning of the buffer Ctrl-s Advance to end of the buffer Ctrl-r Run your buffer from wherever you are in the editor ESC Back to the SQL> prompt

14 TAB Completion If you need a table, column, SQL command in a query, use the TAB key for assistance SQLcl automatically completes the text using the lowest common match available

15 Result Formatting Export a result-set in different formats using SET SQLFORMAT <format> Supported formats include CSV Delimited Insert statements XML JSON Disable it with SET SQLFORMAT

16 Result Formatting Use SET SQLFORMAT ANSICONSOLE to format your query output to fit your window Each page of query results gets measured to establish the best size for each column before printing the output.

17 Format Apply default SQL Developer formatting to the content of the buffer (FORMAT BUFFER) or the content of a file (FORMAT FILE) FORMAT RULES loads a SQL Developer formatter rules file to use it in SQLcl

18 History (His) Stores the last 100 statements/commands that have been executed Can be accessed using the ‘Up’ and ‘Down’ arrow keys Can be accessed using the HISTORY command

19 History (His) Place a statement in the buffer with HISTORY <#>
Execute with /

20 History (His) Use HISTORY CLEAR to cleanup the history list
View the history including the number of executions for each statement/command with HISTORY USAGE

21 History (His) View the observable client time spent executing each statement/command with HISTORY TIME

22 History (His) Use HISTORY FAILS ON/OFF to configure whether failed statements/commands are saved. Disabled by default Use SET HISTORY BLACKLIST to configure what commands should not be saved

23 Information (INFO) For a table displays:
Last analyzed date Number of rows (from stats) In-Memory column store status Comments PK indicated by a * next to the column(s) Column default values Column comments Indexes Referential integrity constraints Output formatted to display as best as possible

24 Information (INFO) Also supports PL/SQL objects. You can use it with an entire package or just individual procedures/functions Prints a code stub that you can paste into your script to execute your PL/SQL

25 Information (INFO+) For tables you can also run INFO+ and it displays column statistics instead of column comments

26 DDL Issue the command with the name of an object, and SQLcl will go get the DDL script to create that object using the DBMS_METADATA package. HELP SET DDL lists the various ways of influencing the DDL generation, but they are the same as the DBMS_METADATA.SET_TRAN SFORM_PARAM procedure

27 CTAS Executes DBMS_METADATA.GET_DDL to extract the DDL for the existing table and builds a create table as select * from command The create table as select command does not run automatically. You have to execute with /

28 Alias Allows re-use frequently used statements or multi-line scripts
Bind variable can be used in the queries. They are defined in the order in which they appear

29 Script SQLcl allows you to run JavaScript to do things that SQLcl does not already support

30 Resources OTN Kris Rice's Blog Jeff Smith's Blog Barry McGillin's Blog

31 Contact Information @GaloBalda galobalda.wordpress.com

32


Download ppt "SQLcl: A Modern Command Line Interface to the Oracle Database"

Similar presentations


Ads by Google