oracle的分号和斜杠/

believefym 2010-05-24 02:37:45
[Quote=]
1. Adding a slash to the end of each statement was a bad choice because sqlplus treats slash as a buffer flush. For procedure/triggers/functions it is a must: because content of if is stored in the buffer and is not executed. However, for all other statements it means executing the same statement twice because such statement is executed immediately and put into buffer and following slash just re-executes the same statement.
[/Quote]

我的理解是,对一些block,比如declare, begin end ,create procedure之类的,'/'是必须的,用来run
而一些简单statement,‘/ '会导致运行两次

问题是,直接用一个'/'就会运行两次,还是在分号之后还在下行跟着 / 才会执行两次?

另外,如果要避免重复执行的话,分号和斜杠是不是二选一就可以了,一般选哪个有啥习惯?
...全文
983 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
phenhorlin2 2012-10-11
  • 打赏
  • 举报
回复
碧水幽幽泉 2010-05-24
  • 打赏
  • 举报
回复
楼上的已经说的很清楚了!
;是执行语句必须的
/是执行语句块必须的
ojuju10 2010-05-24
  • 打赏
  • 举报
回复
如果是语句的话,;表示结束并且运行
如果是程序块或者pl块,;表示结束不允许,必须/表示运行
心中的彩虹 2010-05-24
  • 打赏
  • 举报
回复
[Quote=引用楼主 believefym 的回复:]
引用
1. Adding a slash to the end of each statement was a bad choice because sqlplus treats slash as a buffer flush. For procedure/triggers/functions it is a must: because content of if is stored in th……
[/Quote]

语句中一个;是结束标志
最后一个 ;是执行语句块跟/一样的
iihero_ 2010-05-24
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 believefym 的回复:]

引用 1 楼 tangren 的回复:

1、放在分号后面的 / 会导致两次;sqlplus认为输入“;”表示一个语句结束
2、分号


谢谢。

再问一下
像create procedure,到最后也应该有个分号结束,然后再跟一个斜杠
对这种block的这样没问题吗?
[/Quote]

没有问题,分号只是表示语句结束,并不能断定要执行,加一个/,则表示要执行前边的语句块。
iqlife 2010-05-24
  • 打赏
  • 举报
回复
我的理解是;是执行语句必须的
/是执行语句块必须的
believefym 2010-05-24
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 tangren 的回复:]

1、放在分号后面的 / 会导致两次;sqlplus认为输入“;”表示一个语句结束
2、分号
[/Quote]

谢谢。

再问一下
像create procedure,到最后也应该有个分号结束,然后再跟一个斜杠
对这种block的这样没问题吗?
tangren 2010-05-24
  • 打赏
  • 举报
回复
1、放在分号后面的 / 会导致两次;sqlplus认为输入“;”表示一个语句结束
2、分号

17,377

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 基础和管理
社区管理员
  • 基础和管理社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧