SQLPLUS小技巧带行号SQL的粘贴

介绍一个SQLPLUS中粘贴SQL语句的小技巧。
除了Windows环境下的SQLPLUSW之外,当在sqlplus中运行了一个很长的语句后,得到的是一个带有行号的SQL:

SQL> SELECT ksppinm name,
2 ksppstvl VALUE, 
3 ksppdesc des
4 FROM x$ksppi x, x$ksppcv y 
5 WHERE (x.indx = y.indx) 
6 AND bitand(ksppiflg,268435456) = 0 
7 AND ksppinm LIKE 'max%size';
NAME               VALUE         DES
------------------ ------------- -------------------------------
max_dump_file_size UNLIMITED     Maximum SIZE (blocks) OF dump file


对于上面的结果,如果想要复制粘贴到SQLPLUS中会显得非常麻烦,必需要找到一个支持列选的编辑器,将前面的行号编辑掉,否则虽然也可以粘贴到SQLPLUS中,但是还要通过行编辑方式去掉每行的行号,整个操作显得十分烦琐:

 

显然如果没有列式编辑,处理这种情况会非常麻烦,其实有一个方法可以很方便的处理这种情况,先将第一行粘贴到SQLPLUS中,然后输入两次回车退出当前语句输入模式,然后就可以直接将剩下的所有包含行号的行粘贴到SQLPLUS中:

SQL> SELECT ksppinm name,
2 
SQL> 2 ksppstvl VALUE, 
SQL> 3 ksppdesc des
SQL> 4 FROM x$ksppi x, x$ksppcv y 
SQL> 5 WHERE (x.indx = y.indx) 
SQL> 6 AND bitand(ksppiflg,268435456) = 0 
SQL> 7 AND ksppinm LIKE 'max%size';
SQL> l
1 SELECT ksppinm name,
2 ksppstvl VALUE,
3 ksppdesc des
4 FROM x$ksppi x, x$ksppcv y
5 WHERE (x.indx = y.indx)
6 AND bitand(ksppiflg,268435456) = 0
7* AND ksppinm LIKE 'max%size'
SQL> r
1 SELECT ksppinm name,
2 ksppstvl VALUE,
3 ksppdesc des
4 FROM x$ksppi x, x$ksppcv y
5 WHERE (x.indx = y.indx)
6 AND bitand(ksppiflg,268435456) = 0
7* AND ksppinm LIKE 'max%size'
NAME               VALUE         DES
------------------ ------------- -------------------------------
max_dump_file_size UNLIMITED     Maximum SIZE (blocks) OF dump file


 

SQL> SELECT ksppinm name,
2 
SQL> 2 ksppstvl VALUE, 
SQL> 3 ksppdesc des
SQL> 4 FROM x$ksppi x, x$ksppcv y 
SQL> 5 WHERE (x.indx = y.indx) 
SQL> 6 AND bitand(ksppiflg,268435456) = 0 
SQL> 7 AND ksppinm LIKE 'max%size';
SQL> l
1 SELECT ksppinm name,
2 ksppstvl VALUE,
3 ksppdesc des
4 FROM x$ksppi x, x$ksppcv y
5 WHERE (x.indx = y.indx)
6 AND bitand(ksppiflg,268435456) = 0
7* AND ksppinm LIKE 'max%size'
SQL> r
1 SELECT ksppinm name,
2 ksppstvl VALUE,
3 ksppdesc des
4 FROM x$ksppi x, x$ksppcv y
5 WHERE (x.indx = y.indx)
6 AND bitand(ksppiflg,268435456) = 0
7* AND ksppinm LIKE 'max%size'
NAME               VALUE         DES
------------------ ------------- -------------------------------
max_dump_file_size UNLIMITED     Maximum SIZE (blocks) OF dump file



Oracle在这种情况下会将粘贴语句中的行号真正的作为当前语句的行号。这句话比较难理解,其实在Oracle已经缓冲区中包含多个记录行时,可以通过语句前面添加行号的方式,指定当前的内容替换缓冲区中的第几行:

SQL> 8 abc
SQL> l
1 SELECT ksppinm name,
2 ksppstvl VALUE,
3 ksppdesc des
4 FROM x$ksppi x, x$ksppcv y
5 WHERE (x.indx = y.indx)
6 AND bitand(ksppiflg,268435456) = 0
7 AND ksppinm LIKE 'max%size'
8* abc
SQL> 5 DESC
SQL> l
1 SELECT ksppinm name,
2 ksppstvl VALUE,
3 ksppdesc des
4 FROM x$ksppi x, x$ksppcv y
5 DESC
6 AND bitand(ksppiflg,268435456) = 0
7 AND ksppinm LIKE 'max%size'
8* abc


 

 

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值