免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 5129 | 回复: 11
打印 上一主题 下一主题

bcp in 到底会不会触发触发器? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-04-14 10:57 |只看该作者 |倒序浏览
一直认为bcp in 是不会触发触发器的,不管是慢速还是快速bcp。但有人跟我争,说表上有索引且有触发器的情况下,会触发触发器。被搞糊涂了,请问到底是怎么样的?

论坛徽章:
6
水瓶座
日期:2014-06-04 03:34:37水瓶座
日期:2014-06-17 13:20:31数据库技术版块每日发帖之星
日期:2016-07-09 06:20:00数据库技术版块每日发帖之星
日期:2016-07-17 06:20:00数据库技术版块每日发帖之星
日期:2016-08-01 06:20:00数据库技术版块每日发帖之星
日期:2016-08-04 06:20:00
2 [报告]
发表于 2010-04-14 11:32 |只看该作者
会,不信自己试一下!

论坛徽章:
33
ChinaUnix元老
日期:2018-07-04 15:10:362015年亚洲杯之阿联酋
日期:2015-02-06 17:15:532015亚冠之武里南联
日期:2015-06-06 15:40:252015亚冠之北京国安
日期:2015-06-17 15:42:412022北京冬奥会纪念版徽章
日期:2015-08-10 16:30:322015亚冠之阿尔纳斯尔
日期:2015-09-20 09:42:1215-16赛季CBA联赛之北京
日期:2016-01-15 10:03:5915-16赛季CBA联赛之青岛
日期:2016-04-26 16:44:4915-16赛季CBA联赛之广夏
日期:2018-07-04 15:33:21C
日期:2016-10-25 16:12:142017金鸡报晓
日期:2017-01-10 15:19:5615-16赛季CBA联赛之同曦
日期:2017-02-22 22:41:10
3 [报告]
发表于 2010-04-14 14:14 |只看该作者
bcp IN之前,最好把触发器及索引删了,导入完成后重建,这样做一是保证BCP导入速度,二是为了数据安全!

论坛徽章:
0
4 [报告]
发表于 2010-04-14 15:06 |只看该作者
会触发的

论坛徽章:
0
5 [报告]
发表于 2010-04-15 11:03 |只看该作者
bcp does not fire any trigger that exists on the target table.

这个是手册上的原话

试验过,肯定不会触发trigger。

论坛徽章:
6
水瓶座
日期:2014-06-04 03:34:37水瓶座
日期:2014-06-17 13:20:31数据库技术版块每日发帖之星
日期:2016-07-09 06:20:00数据库技术版块每日发帖之星
日期:2016-07-17 06:20:00数据库技术版块每日发帖之星
日期:2016-08-01 06:20:00数据库技术版块每日发帖之星
日期:2016-08-04 06:20:00
6 [报告]
发表于 2010-04-15 13:56 |只看该作者
回复 5# D_D_D_D


    哪儿看到的?请贴出详细的原文来。 并标记出来源!

论坛徽章:
0
7 [报告]
发表于 2010-04-15 14:36 |只看该作者
呵呵,看到5楼的兄弟回答,我去查找了一下手册,手册上确实有说不会引起触发器,不过这个是在15.0版本之后,之前的版本是会的。原文我给大家引用一下,仅供大家参考。
These are situations in which Adaptive Server version 15.0.2 uses fast bcp but earlier versions Adaptive Server used slow bcp (in all cases sp_dboption ‘select into/bulkcopy/pllsort’ is enabled and the table does not have a clustered index):

When the table has a non-unique, nonclustered index. Adaptive Server logs the index updates and the page allocations only. It does not log inserts into the table.

When a table has triggers. However, bcp does not fire any triggers in the target table.

When a table has datarows or datapage locking scheme with a clustered index.


12.5.2的Utility Guide中指出
bcp clarification
In the section “bcp modes” in Chapter 3, “Using bcp to Transfer Data to and from Adaptive Server” in the Utility Guide, the definitions of bcp in were reversed and incorrectly stated as:

bcp in works in one of two modes:

Fast bcp – logs each row insert that it makes, used for tables that have one or more indexes or triggers.

Slow bcp – logs only page allocations, copying data into tables without indexes or triggers at the fastest speed possible.

The correct definitions are as follows:

bcp in works in one of two modes:

Slow bcp – logs each row insert that it makes, used for tables that have one or more indexes or triggers.

Fast bcp – logs only page allocations, copying data into tables without indexes or triggers at the fastest speed possible.


在15.0.3手册中又指出
Adaptive Server Enterprise 15.0.3 > Adaptive Server Enterprise Cluster Edition 15.0.3 Clusters Users Guide > System Changes > Utilities > Changes to utility programs
  

Chapter 15: System Changes
--------------------------------------------------------------------------------

bcp
Versions earlier than 15.0.3 did not allow you to run fast bcp on tables with non-clustered indexes or triggers. Cluster Edition version 15.0.3 and later removes this restriction. See the Utility Guide.

论坛徽章:
0
8 [报告]
发表于 2010-04-15 16:20 |只看该作者
大家再试试吧,我刚试完了,确实不会触发触发器。有索引,有视图,有insert,update,delete的trigger

而且版主贴的文章应该是描述快速bcp和慢速bcp的,而不是说bcp时会不会cause trigger to  fire。

只要表上有触发器或索引之一,就是慢速bcp,没有索引和触发器,就是快速。

论坛徽章:
0
9 [报告]
发表于 2010-04-27 18:10 |只看该作者

论坛徽章:
0
10 [报告]
发表于 2010-04-27 18:11 |只看该作者
:wink:
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP