- 修改
- 追加
- 插入
- 删除
无论对sqlplus buffer进行修改、追加还是插入操作都必须将操作的对象修改为当前行
设置当前行方式有两种
1.直接输入行号
2.list + 行号
一、修改
修改beffer中的值
SQL> select count(*) 2 from bonus 3 ; COUNT(*) ---------- 100 SQL> l 1 select count(*) 2 from bonus 3*
此时buffer中有3行内容,*号开头代表当前行是第三行
将count(*)修改为*
1.将第一行设置为当前行
SQL> 1 1* select count(*)
2.使用change/原始数据/替换数据 格式替换掉conut(*)
SQL> c/count(*)/* 1* select * SQL> l 1 select * 2 from bonus 3*
此时buffer中的内容修改成功
另外一种修改的方式是覆盖格式为修改的行号+覆盖的值
SQL> l 1 select * 2* from bonus SQL> 1 select count(*) SQL> l 1 select count(*) 2* from bonus
3.change也可以做删除使用
格式为c/要删除的值
SQL> l 1 /* this is demo */ 2 select * 3 this is new line 4 from bonus 5* SQL> 1 1* /* this is demo */ SQL> c/this 1* /* is demo */ SQL> l 1 /* is demo */ 2 select * 3 this is new line 4 from bonus 5*
二、追加
在buffer中追加一个where子句
首先应该做的是,将要追加的行变成当前行
SQL> l 1 select * 2 from bonus 3* SQL> 2 2* from bonus
使用append 要追加的内容 格式追加
注意append后边要跟两个空格,否则会成为
SQL> append where sal = 99 2* from bonuswhere sal = 99 SQL> l 1 select * 2 from bonuswhere sal = 99 3*
正确方式应该为
SQL> a where sal = 99 2* from bonuswhere sal = 99 SQL> l 1 select * 2 from bonus where sal = 99 3*
三、插入
在select *前一行增加注释
因为select *为1所以格式为0+要插入的值
SQL> l 1 select * 2 from bonus 3* SQL> 0 /* this is demo */ SQL> l 1 /* this is demo */ 2 select * 3 from bonus 4*
如果插入2,3行之间,首先将第2行变成当前行,使用input+要插入的值来插入数据
SQL> l 1 /* this is demo */ 2 select * 3 from bonus 4* SQL> 2 2* select * SQL> input this is new line SQL> l 1 /* this is demo */ 2 select * 3 this is new line 4 from bonus 5*
四、删除
del关键字
SQL> help del DEL --- Deletes one or more lines of the SQL buffer. The buffer has no command history list and does not record SQL*Plus commands. DEL [n | n m | n * | n LAST | * | * n | * LAST | LAST]
del n 删除第n行
del n m 删除第n到m行
del n * 删除第n到当前行
del n LAST 删除第n到最后一行
del * 删除当前行
del * n 删除当前行到n行(n>*)
del * LAST 删除当前行到最后一行
del LAST 删除最后一行
del与list参数相同,只是将删除二字更换为显示