楼主: lastwinner

[原创] 【讨论】SQL脚本中注释的陷阱

[复制链接]
求职 : 数据库管理员
论坛徽章:
11
ITPUB社区千里马徽章
日期:2013-06-09 10:15:34懒羊羊
日期:2015-03-04 14:52:11懒羊羊
日期:2015-02-10 13:36:05马上有对象
日期:2015-02-02 12:29:02红宝石
日期:2015-01-19 09:44:10马上有车
日期:2014-11-11 14:16:07马上有车
日期:2014-03-27 15:59:39优秀写手
日期:2014-03-12 06:00:13马上有钱
日期:2014-02-18 16:43:092014年新春福章
日期:2014-02-18 16:43:09
31#
发表于 2014-10-28 08:50 | 只看该作者
YuBinTAMU 发表于 2014-10-27 20:47
In sql*plus , / is used for execute the current statement in SQL buffer.

22正解,后面加个“;”试试

使用道具 举报

回复
论坛徽章:
142
秀才
日期:2016-01-06 14:01:09秀才
日期:2016-02-18 10:06:46秀才
日期:2016-02-18 10:08:02秀才
日期:2016-02-18 10:08:14秀才
日期:2016-03-01 09:57:08天蝎座
日期:2016-03-18 14:23:56秀才
日期:2016-03-24 09:10:24秀才
日期:2016-03-24 09:20:52秀才
日期:2016-04-21 14:08:53秀才
日期:2016-04-21 14:11:59
32#
发表于 2014-10-28 09:01 | 只看该作者
看看结果

使用道具 举报

回复
论坛徽章:
26
2010年世界杯参赛球队:阿根廷
日期:2010-07-15 16:49:17马上加薪
日期:2014-10-30 09:48:58马上有车
日期:2014-11-04 14:03:06马上有钱
日期:2015-01-13 10:14:512015年新春福章
日期:2015-03-04 14:51:122015年新春福章
日期:2015-03-06 11:57:31喜羊羊
日期:2015-03-16 10:05:36慢羊羊
日期:2015-06-02 11:57:03慢羊羊
日期:2015-06-17 16:43:46巨蟹座
日期:2015-10-19 10:12:48
33#
发表于 2014-10-28 09:46 | 只看该作者
let me see.

使用道具 举报

回复
论坛徽章:
223
2010新春纪念徽章
日期:2010-03-01 11:20:51ITPUB元老
日期:2019-04-25 13:46:07至尊黑钻
日期:2015-08-13 13:38:12至尊黑钻
日期:2015-02-15 09:47:472015年中国系统架构师大会纪念徽章
日期:2015-07-31 17:48:20管理团队2007贡献徽章
日期:2015-01-19 09:48:272015中国数据库技术大会纪念徽章
日期:2015-05-15 14:08:23海蓝宝石
日期:2015-02-03 10:23:39红宝石
日期:2015-02-03 10:26:04会员2007贡献徽章
日期:2015-02-03 10:26:41
34#
发表于 2014-10-28 09:48 | 只看该作者
回一下,再看帖子内容。

使用道具 举报

回复
论坛徽章:
484
ITPUB北京香山2007年会纪念徽章
日期:2007-01-24 14:35:02ITPUB北京九华山庄2008年会纪念徽章
日期:2008-01-21 16:50:24ITPUB北京2009年会纪念徽章
日期:2009-02-09 11:42:452010新春纪念徽章
日期:2010-03-01 11:04:552010数据库技术大会纪念徽章
日期:2010-05-13 10:04:272010系统架构师大会纪念
日期:2010-09-04 13:35:54ITPUB9周年纪念徽章
日期:2010-10-08 09:28:512011新春纪念徽章
日期:2011-02-18 11:43:32ITPUB十周年纪念徽章
日期:2011-11-01 16:19:412012新春纪念徽章
日期:2012-01-04 11:49:54
35#
 楼主| 发表于 2014-10-28 10:25 | 只看该作者
oracle_cj 发表于 2014-10-27 22:15
大湿,你这个sql在plsql developer中的sql window窗口肯定会报错吧

不知道啊,我在sqlplus中发现的

使用道具 举报

回复
论坛徽章:
484
ITPUB北京香山2007年会纪念徽章
日期:2007-01-24 14:35:02ITPUB北京九华山庄2008年会纪念徽章
日期:2008-01-21 16:50:24ITPUB北京2009年会纪念徽章
日期:2009-02-09 11:42:452010新春纪念徽章
日期:2010-03-01 11:04:552010数据库技术大会纪念徽章
日期:2010-05-13 10:04:272010系统架构师大会纪念
日期:2010-09-04 13:35:54ITPUB9周年纪念徽章
日期:2010-10-08 09:28:512011新春纪念徽章
日期:2011-02-18 11:43:32ITPUB十周年纪念徽章
日期:2011-11-01 16:19:412012新春纪念徽章
日期:2012-01-04 11:49:54
36#
 楼主| 发表于 2014-10-28 10:29 | 只看该作者
YuBinTAMU 发表于 2014-10-27 20:47
In sql*plus , / is used for execute the current statement in SQL buffer.

我确信你没完全理解我给出的脚本

/****recreation done****/ 为何就没让创建sequence的脚本再执行一次呢?

使用道具 举报

回复
论坛徽章:
484
ITPUB北京香山2007年会纪念徽章
日期:2007-01-24 14:35:02ITPUB北京九华山庄2008年会纪念徽章
日期:2008-01-21 16:50:24ITPUB北京2009年会纪念徽章
日期:2009-02-09 11:42:452010新春纪念徽章
日期:2010-03-01 11:04:552010数据库技术大会纪念徽章
日期:2010-05-13 10:04:272010系统架构师大会纪念
日期:2010-09-04 13:35:54ITPUB9周年纪念徽章
日期:2010-10-08 09:28:512011新春纪念徽章
日期:2011-02-18 11:43:32ITPUB十周年纪念徽章
日期:2011-11-01 16:19:412012新春纪念徽章
日期:2012-01-04 11:49:54
37#
 楼主| 发表于 2014-10-28 10:42 | 只看该作者
newkid 发表于 2014-10-27 22:25
我在11.2.0.3的sqlplus执行,也被坑了。这个我认为是sqlplus的bug.
我写注释坚持用-- 看来不是没有道理的。 ...

经过仔细测试,/*后面如果紧跟字母就会导致重复插入(中文也如是),但如果紧跟的是标点、数字等,就没事
  1. lastwinner@lw2> insert into emp(empno, ename) values(emp_seq.nextval,'lastwiner');

  2. 已创建 1 行。

  3. lastwinner@lw2> /*atfer insert a row, let's query*/

  4. 已创建 1 行。

  5. lastwinner@lw2> /* atfer insert a row, let's query*/
  6. lastwinner@lw2> /**atfer insert a row, let's query*/
  7. lastwinner@lw2> /*!atfer insert a row, let's query*/
  8. lastwinner@lw2> /*atfer insert a row, let's query*/

  9. 已创建 1 行。

  10. lastwinner@lw2> /*0atfer insert a row, let's query*/
  11. lastwinner@lw2> /*-atfer insert a row, let's query*/
  12. lastwinner@lw2> /*+atfer insert a row, let's query*/
  13. lastwinner@lw2> /*.atfer insert a row, let's query*/
  14. lastwinner@lw2> /*,atfer insert a row, let's query*/
  15. lastwinner@lw2> /*/atfer insert a row, let's query*/
  16. SP2-0734: 未知的命令开头 "atfer inse..." - 忽略了剩余的行。
  17. lastwinner@lw2> /*\/atfer insert a row, let's query*/
  18. lastwinner@lw2> /*atfer insert a row, let's query*/

  19. 已创建 1 行。

  20. lastwinner@lw2>
复制代码

使用道具 举报

回复
论坛徽章:
484
ITPUB北京香山2007年会纪念徽章
日期:2007-01-24 14:35:02ITPUB北京九华山庄2008年会纪念徽章
日期:2008-01-21 16:50:24ITPUB北京2009年会纪念徽章
日期:2009-02-09 11:42:452010新春纪念徽章
日期:2010-03-01 11:04:552010数据库技术大会纪念徽章
日期:2010-05-13 10:04:272010系统架构师大会纪念
日期:2010-09-04 13:35:54ITPUB9周年纪念徽章
日期:2010-10-08 09:28:512011新春纪念徽章
日期:2011-02-18 11:43:32ITPUB十周年纪念徽章
日期:2011-11-01 16:19:412012新春纪念徽章
日期:2012-01-04 11:49:54
38#
 楼主| 发表于 2014-10-28 10:43 | 只看该作者
newkid 发表于 2014-10-27 23:11
是你的编辑器干的吧?
我从来没有碰到被强行换行的情况。

同感,而且猜测是 notepad 搞的鬼

使用道具 举报

回复
论坛徽章:
484
ITPUB北京香山2007年会纪念徽章
日期:2007-01-24 14:35:02ITPUB北京九华山庄2008年会纪念徽章
日期:2008-01-21 16:50:24ITPUB北京2009年会纪念徽章
日期:2009-02-09 11:42:452010新春纪念徽章
日期:2010-03-01 11:04:552010数据库技术大会纪念徽章
日期:2010-05-13 10:04:272010系统架构师大会纪念
日期:2010-09-04 13:35:54ITPUB9周年纪念徽章
日期:2010-10-08 09:28:512011新春纪念徽章
日期:2011-02-18 11:43:32ITPUB十周年纪念徽章
日期:2011-11-01 16:19:412012新春纪念徽章
日期:2012-01-04 11:49:54
39#
 楼主| 发表于 2014-10-28 10:43 | 只看该作者
demonat 发表于 2014-10-27 17:50
为啥要回复可见

嗯,留给大家思考的空间

使用道具 举报

回复
论坛徽章:
16
授权会员
日期:2005-11-01 10:49:02ITPUB十周年纪念徽章
日期:2011-09-27 16:30:472011新春纪念徽章
日期:2011-02-18 11:43:322010年世界杯参赛球队:南非
日期:2010-05-12 11:08:572010新春纪念徽章
日期:2010-03-01 11:04:542009新春纪念徽章
日期:2009-01-04 14:52:28生肖徽章2007版:狗
日期:2008-10-31 12:50:13生肖徽章2007版:狗
日期:2008-10-24 18:01:04奥运会纪念徽章:排球
日期:2008-10-24 13:30:01生肖徽章2007版:狗
日期:2008-10-20 14:41:16
40#
发表于 2014-10-28 10:44 | 只看该作者
lastwinner 发表于 2014-10-27 16:07
下面是在Oracle 11.2.0.1下运行的结果
**** 本内容被作者隐藏 ****

使用道具 举报

回复

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

TOP技术积分榜 社区积分榜 徽章 团队 统计 知识索引树 积分竞拍 文本模式 帮助
  ITPUB首页 | ITPUB论坛 | 数据库技术 | 企业信息化 | 开发技术 | 微软技术 | 软件工程与项目管理 | IBM技术园地 | 行业纵向讨论 | IT招聘 | IT文档
  ChinaUnix | ChinaUnix博客 | ChinaUnix论坛
CopyRight 1999-2011 itpub.net All Right Reserved. 北京盛拓优讯信息技术有限公司版权所有 联系我们 未成年人举报专区 
京ICP备16024965号-8  北京市公安局海淀分局网监中心备案编号:11010802021510 广播电视节目制作经营许可证:编号(京)字第1149号
  
快速回复 返回顶部 返回列表