SQL*Plus Command -- history

语法:HIST[ORY] [n RUN | EDIT | DEL[ETE]] | [CLEAR | LIST]

功能:使用history命令查看历史SQL命令,并可以再次执行、编辑、删除这些历史命令。

        使用history命令的前提是已经set history开启了缓存历史SQL命令的功能。当SQL数量超过了最大保留值时,自动清除最旧的数据,并重新生成从1开始的连续的序号。

set  history  100        设置缓存100条历史SQL记录。

set  history  off          设置关闭缓存。

history                       查看所有缓存的历史SQL命令。

history  list                查看所有缓存的历史SQL命令。等同于单独执行history命令。

history  n  run           执行缓存记录中的第n条SQL命令。编号前的星号(*)表示最后执行的SQL。

history  n  edit           编辑缓存中的第n条SQL命令,编辑后的新SQL作为新记录保存在缓存列表最后,原SQL记录信息不变。

history  n  delete       删除缓存中的第n条SQL命令,其它历史SQL将重新产生连续的序号。

history   clear            清空缓存列表。

        在使用编辑命令时,可以先用DEFINE命令设置_EDITOR来指定文本编辑器的名称,如使用vi编辑器:

DEFINE _EDITOR = vi

        开启和关闭history功能:

SQL> set history on
SQL> show history
History is ON and set to "100"
SQL> set history off
SQL> show history
History is OFF
SQL> set history 200
SQL> show history
History is ON and set to "200"

        查看历史SQL记录:

SQL> show history
history is OFF
SQL> set history on
SQL> show history
history is ON and set to "100"
SQL> select max(id) id from tt;
 id
----
 23
 
SQL> select 1 from dual;
 1
---
 1
 
SQL> history
1 show history
2 select max(id) id from tt;
3 select 1 from dual;

SQL> history 2 run
 id
----
 23
 
SQL> history                  //编号前的星号(*)表示最后执行的SQL
 1 show history
*2 select max(id) id from tt;
 3 select 1 from dual;

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值