Using the ttIsql Command History
The ttIsql
utility stores a list of the last 100 commands that ran
within the current ttIsql
session. The commands in this list can be viewed
or run again without having to type the entire command over.
Both SQL statements and built-in ttIsql
commands are stored in the
history list. Use the history
command ("h
") to view
the list of previous commands. For example:
Command> h; 8 INSERT INTO T3 VALUES (3) 9 INSERT INTO T1 VALUES (4) 10 INSERT INTO T2 VALUES (5) 11 INSERT INTO T3 VALUES (6) 12 autocommit 0 13 showplan 14 SELECT * FROM T1, t2, t3 WHERE A=B AND B=C AND A=B 15 trytbllocks 0 16 tryserial 0 17 SELECT * FROM T1, t2, t3 WHERE A=B AND B=C AND A=B Command>
The history
command displays the last 10 SQL statements or ttIsql
built-in commands that were run. To display more than that last 10 commands specify the maximum number to display as an argument to the history
command.
Each entry in the history list is identified by a unique number. The !
character followed by the number of the command can be used to run the command again. For example:
Command> Command> ! 12; autocommit 0 Command>
To run the last command again simply type a sequence of two !
characters:
Command> !!; autocommit 0 Command>
To run the last command that begins with a given string type the !
character followed by the first few letters of the command. For example:
Command> ! auto; autocommit 0 Command>
Saving and Clearing the ttIsql Command History
You can save the list of commands that ttIsql
stores by using the
savehistory
command.
savehistory history.txt;
If the output file already exists, use the -a
option to append the new command history to the file or the -f
option to overwrite the file. The next example shows how to append new command history to an existing file.
savehistory -a history.txt;
You can clear the list of commands that ttIsql
stores by using the
clearhistory
command:
clearhistory;