sql username/password@//hostname:port/service_name
sql username/password@tns_alias
Here are some examples:
sql HR/HR@//localhost:1521/ORCL
sql HR/HR@orcl_tns
set echo on
set define off
set timing on
set time on
Most of sqlplus features exists. But you heve more options to change the prompt:
set sqlprompt "_USER @_CONNECT_IDENTIFIER >"
set time on
09:48:37 sagivba @my_db >
examples:
Tab
: Auto-completes commands, keywords, table names, and more.Ctrl + C
: Interrupts the currently running command or script.Ctrl + L
: Clears the screen, providing a clean command-line interface.Ctrl + D
: Exits SQLcl and closes the current session.Up Arrow|Down Arrow : Scrolls through previously |
next entered commands. |
Ctrl + R
: Initiates a reverse search in command history. Press repeatedly to cycle through matching commands.Ctrl + E
: Moves the cursor to the end of the current line.Ctrl + A
: Moves the cursor to the beginning of the current line.Ctrl + U
: Clears the current line from the cursor position to the beginning.Ctrl + K
: Clears the current line from the cursor position to the end.Ctrl + W
: Deletes the word to the left of the cursor.Ctrl + Y
: Pastes the last deleted or cut text.Ctrl + H
: Shows the command history.Ctrl + P
: Moves to the previous line in the command history.Ctrl + N
: Moves to the next line in the command history.Ctrl + T
: Swaps the current character with the previous one.Ctrl + F
: Moves the cursor forward one character.Ctrl + B
: Moves the cursor backward one character.Ctrl + Z
: Suspends the current SQLcl session. Use the fg command to bring it back to the foreground.Ctrl + S
: Stops the output from scrolling, useful for reviewing large outputs.DEFAULT|CSV|HTML|XML|JSON|ANSICONSOLE|INSERT|LOADER|FIXED|DELIMITED
DEFAULT
- The DEFAULT option clears all previous SQLFORMAT settings and returns to the default output.ANSICONSOLE
- The ANSICONSOLE format resizes the columns to the width of the data to save space.INSERT
- The INSERT format produces the INSERT statements that could be used to recreate the rows in a table.LOADER
- The LOADER format produces pipe delimited output with string values enclosed by double-quotes. The column names are not included in the output.
this format is useful for generating SQLLoader control files.DELIMITED <delimiter> <left enclosure> <right enclosure>
- The DELIMITED format is a special case, which allows you to manually define the delimiter string, as well as the characters that will be used to enclose string values. The basic format is as follows.SELECT /*csv*/ * FROM emp;
SELECT /*html*/ * FROM emp;
SET SQLFORMAT JSON-FORMATTED
SELECT * FROM emp WHERE deptno = 20;
SET SQLFORMAT csv
SPOOL sales_export.csv
SELECT order_id, customer_name, order_amount, order_date
FROM sales_data;
SPOOL OFF
EXIT;
Lets save the example above as file:generate_report.sql
Here is an example of data export into csv file
sql user/password@mytns_name @generate_report.sql
SET SQLFORMAT csv
-- Load data from the CSV file into the employee_data table
-- Note: You might need to adjust the column names and delimiter based on your
-- CSV format
LOAD DATA
INFILE 'employee_import.csv'
APPEND
INTO TABLE employee_data
FIELDS TERMINATED BY ','
(employee_id, first_name, last_name, job_id)
This command list all installed APEX applications in a workspace. We can also list applications in a workspace changed on or after a given date
apex export -list -workspaceid 1908816359534887 -changesSince 2022-01-15
export an application to a single file
apex export -applicationid 1234
Exporting an Application Split into Multiple Files
apex export -applicationid 1234 -split