Skip to content

Convenient User Functions

Convenient User Functions#

History#

A list of all previously executed commands can be displayed using the HISTORY command. The number corresponding to a previously executed command can be used to easily execute that command again.

iSQL> HISTORY;  -- View history list

or

iSQL> H;        
1 : SELECT * FROM tab;
2 : SELECT * FROM book;
3 : HISTORY;

iSQL> /         -- Re-execute the most recent command(HISTORY;))
iSQL> 2/        -- Execute Command number 2 in history list(SELECT * FROM book;)

History Logging#

It saves the commands executed in iSQL to a file when you exit iSQL. Enabling this function loads previous commands stored in the file when iSQL is restarted. Therefore, previous commands are accessible and executable by using the arrow keys on the keyboard.

To use the history logging function, ISQL_HIST_FILE environment variable should be set and iSQL has to be restarted.

$ export ISQL_HIST_FILE=~/.isql_history

To turn off the history logging function, delete the ISQL_HIST_FILE environment variable.

$ unset ISQL_HIST_FILE

Default Value#

Not used

Constraints#

  • This function can only be used when previous commands are accessible by using the arrow keys on command prompt or shell prompt.
  • Maximum 100 commands can be stored.

File access control should be well taken care of when this function is used since every command the user entered is stored in the file, including sensitive information such as user passwords.

Shell Commands#

The exclamation point ("!") is a convenient function that allows direct execution of most shell commands from within iSQL.

iSQL> !ls -al
total 3417
-rw-r-----   1 altibase altibase      1198 Nov  1 13:30 .aliases
-rw-------   1 altibase altibase      5353 Oct 18 21:17 .bash_history
-rw-r-----   1 altibase altibase      1436 Nov  2 15:42 .bashrc
-rw-r-----   1 altibase altibase      1549 Dec 13 17:36 .profile

Command Prompt#

The prompt can be modified by configuting other values instead of the fundamental command prompt 'iSQL>'. The SET SQLPROMPT dynamically replaces variables when including runtime variables, such as current accessed user, and current time.

SET SQLP[ROMPT] {text}

The followings are the substitution variables available for use.

Variable Description
_CONNECT_IDENTIFIER The connected server. It is expressed with " host:port_no ".
_DATE The current time. It is expressed through a specified format in the DATE_FORMAT.
_PRIVILEGE This variable displays the iSQL access privilege. If it is connected with sysdba, '(sysdba)' is replaced.
_USER The user name currently being connected.

Example#

iSQL>SET SQLPROMPT "_CONNECT_IDENTIFIER> "

iSQL>SET SQLP "_USER> "

iSQL>SET SQLPROMPT "_USER'@'_CONNECT_IDENTIFIER > "

iSQL>SET SQLPROMPT "_USER on _DATE from _CONNECT_IDENTIFIER> "

Getting Help#

Help is available for the commands provided with iSQL. The HELP command without parameters outputs information on how to use help. For help on specific commands, enter HELP followed by the name of the command for which help is desired.

iSQL> HELP;
Use 'help [command]'
Enter 'help index' for a list of command
iSQL> HELP INDEX;
/               EXIT            PARTITIONS
@               EXPLAINPLAN     QUERYLOGGING
ALTER           FEEDBACK        QUIT
AUTOCOMMIT      FOREIGNKEYS     ROLLBACK
CHKCONSTRAINTS  FULLNAME        SAVE
CL[EAR]         H[ISTORY]       SELECT
COL[UMN]        HEADING         SPOOL
COLSIZE         INSERT          SQLP[ROMPT]
COMMIT          LINESIZE        START
CREATE          LOAD            TERM
DEFINE          LOBOFFSET       TIMESCALE
DELETE          LOBSIZE         TIMING
DESC            MERGE           UPDATE
DROP            MOVE            USER
ECHO            NUM[WIDTH]      VAR[IABLE]
EDIT            NUMF[ORMAT]     VERTICAL
EXECUTE         PAGESIZE

iSQL> HELP EXIT;
exit;
or
quit; - exit iSQL