How can I execute previous commands without re-typing them. Usually under
*nix, I can press the UP Arrow key to toggle previous statements.
Thanks,
Chris
Daniel Morgan
As it has been said, '/'
And if you want to change something in the buffer, to avoid you to type
again the whole line, just do :
c/old_string/new_string/
and / to re-execute...
...and it's done ! :-)
--
CJ
Marseille, FRANCE
(remove '_nospam' for replying)
press the '/' key followed by the 'Enter' key
If you know emacs, run it within an emacs shell and you can ESC-p/n to
walk up and down the history tree. Very cool.
--
Pablo Sanchez, High-Performance Database Engineering
www.hpdbe.com
Available for short-term and long-term contracts
sql.el is sqlplus piggybacking on the shell mode. Comes with the main
Emacs distribution.
Has all the shell mode power you are alluding to along with some
particulars for sql. One of them being able to put a buffer in sql-mode
and typing C-c C-r to send region. I stay in the sqlplus buffer mainly
cause the editing of that buffer is great. I code sql in another
buffer, hop to the sqlplus buffer, hit xf for explain, then x to run the
explain file. Once the plan looks good, I M-p M-p to get the previous
code back and execute it.
In the spirit of Emacs sharing, here are my abbreviations enabled for
sql modes. These sure do make the "all-the-time" SQL much less time
consuming.
(define-abbrev sql-mode-abbrev-table "ss" "select * from" nil)
(define-abbrev sql-mode-abbrev-table "sc" "select count(*) from" nil)
(define-abbrev sql-mode-abbrev-table "scd" "select count(distinct" nil)
(define-abbrev sql-mode-abbrev-table "sd" "select distinct" nil)
(define-abbrev sql-mode-abbrev-table "d" "desc" nil)
(define-abbrev sql-mode-abbrev-table "c" "count(*)" nil)
(define-abbrev sql-mode-abbrev-table "s" "select" nil)
(define-abbrev sql-mode-abbrev-table "f" "from" nil)
(define-abbrev sql-mode-abbrev-table "g" "group by" nil)
(define-abbrev sql-mode-abbrev-table "o" "order by" nil)
(define-abbrev sql-mode-abbrev-table "w" "where" nil)
(define-abbrev sql-mode-abbrev-table "tt" "truncate table" nil)
(define-abbrev sql-mode-abbrev-table "ct" "create table" nil)
(define-abbrev sql-mode-abbrev-table "ii" "insert into" nil)
(define-abbrev sql-mode-abbrev-table "ei" "execute immediate" nil)
(require 'tempo)
;; Dynamically build "select blah,count(*) from tbl group by blah;"
(tempo-define-template
"select-count-group-by" ;; template name
'((p "Table Selected From: " tsf 'NOINSERT)
(p "Fields To Group On: " fgo 'NOINSERT)
"SELECT "
(s fgo)
",count(*) " n>
"from "
(s tsf) n>
" group by "
(s fgo)
";"))
(define-abbrev sql-mode-abbrev-table "scg" "" 'tempo-template-select-count-group-by)
(define-abbrev sql-mode-abbrev-table "xf" "explain plan for" nil)
(define-abbrev sql-mode-abbrev-table "x" "@explain" nil)
(define-abbrev sql-mode-abbrev-table "do" "dbms_output.put_line()" nil)
(define-abbrev sql-mode-abbrev-table "ash" "alter session set HASH_AREA_SIZE=" nil)
(define-abbrev sql-mode-abbrev-table "ass" "alter session set SORT_AREA_SIZE=" nil)
(define-abbrev sql-mode-abbrev-table "ast" "alter session set timed_statistics=;" nil)
(define-abbrev sql-mode-abbrev-table "asst" "alter session set sql_trace=")
(define-abbrev sql-mode-abbrev-table "asev" "alter session set events '10046 trace name context forever, level 12';")
(define-abbrev sql-mode-abbrev-table "sl" "set linesize")
(define-abbrev sql-mode-abbrev-table "st" "set timing")
--
Galen deForest Boyer
Sweet dreams and flying machines in pieces on the ground.
Hi Chris,
If I understand you correctly, then you want to be able to recall
any and all of your previously entered SQL statements from within
an SQL*Plus seesion, correct?
As far as I know, it is only possible to recall the last entered
SQL statement since SQL*Plus only has a single buffer that only
holds the last entered SQL statement. I have seen this behaviour
on Solaris, HP-UX and AIX.
There may be different behaviour on platforms other than these,
I don't know.
The other responders have indicated to you how to recall the last
entered SQL statement (from within SQL*Plus). What they failed to
mention was:
1. type "l" (the letter "ell") to display the last entered SQL
statement
2. type "edit" to start up the default editor to enable editing
of the last entered SQL statement.
All of this is explained in the SQL*Plus Users Guide which is
available from:
Good Luck,
Avi.