SQLcl: A Modern Command Line Interface to the Oracle Database

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

Transcript of SQLcl: A Modern Command Line Interface to the Oracle Database

PowerPoint Presentation

SQLcl: A Modern Command Line Interface to the Oracle DatabaseGalo BaldaSeptember 18, 2016

1

About Me

Ecuador

Austin, TX

3

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

Agenda

4

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

5

SQLcl: Release 4.2.0 requires JRE 1.8.0_50 or higher

Copying a specific JRE install to SQLCL_HOME\bin forces to use that JRE

How do I get started?

6

Get the .ZIP from OTN

Unzip it

No installer or setupHow do I get started?

7

Start a terminal/cmd session

Run the SQL program in SQLCL_HOME/bin

No need for the Oracle clientHow do I get started?

8

TNS: hr/oracle looks at the $TWO_TASK, $ORACLE_HOME, $TNS_ADMIN environment variables

EZConnect: hr/oracle@localhost:1521/orcl

LDAP

SSH Tunnel

WalletConnecting to the Database

9

Supported commands available from the HELP command

New commands are highlightedIm in, wheres the good stuff?

10

HELP prints the commands description and examples

Help topics also available for system variablesIm in, wheres the good stuff?

11

No need to jump to an external editor

Use the arrow keys to move through your query

The EDIT command is still availableMulti-line editing

12

Ctrl-a Advance to beginning of current lineCtrl-e Advance to end of current lineCtrl-w Advance to beginning of the bufferCtrl-s Advance to end of the bufferCtrl-r Run your buffer from wherever you are in the editorESC Back to the SQL> promptMulti-line editing

13

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 availableTAB Completion

14

Export a result-set in different formats using SET SQLFORMAT

Supported formats includeCSVDelimitedInsert statementsXMLJSON

Disable it with SET SQLFORMATResult Formatting

15

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.Result Formatting

16

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 SQLclFormat

17

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 commandHistory (His)

18

Place a statement in the buffer with HISTORY

Execute with /History (His)

19

Use HISTORY CLEAR to cleanup the history list

View the history including the number of executions for each statement/command with HISTORY USAGEHistory (His)

20

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

21

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 savedHistory (His)

22

For a table displays:Last analyzed dateNumber of rows (from stats)In-Memory column store statusCommentsPK indicated by a * next to the column(s)Column default valuesColumn commentsIndexesReferential integrity constraints

Output formatted to display as best as possible

Information (INFO)

23

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/SQLInformation (INFO)

24

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

25

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_TRANSFORM_PARAM procedure

DDL

26

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 /CTAS

27

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 appearAlias

28

SQLcl allows you to run JavaScript to do things that SQLcl does not already supportScript

29

OTN

Kris Rice's Blog

Jeff Smith's Blog

Barry McGillin's BlogResources

30

Contact [email protected]

@GaloBaldagalobalda.wordpress.com

31