zoukankan      html  css  js  c++  java
  • hubbledotnet 定时更新索引

    文章:http://www.cnblogs.com/eaglet/archive/2010/08/25/1808143.html

    这里用的是update模式创建表

    1、首先在数据库中创建触发器表 

    CREATE TABLE [HBTrigger_job_SearchKey] (

    [Serial] [bigint]  IDENTITY (1, 1)  NOT NULL,

    [Id] [intNOT NULL,

    [Opr] [char]  (16) NULL,

    [Fields] [nvarchar]  (4000) NULL)

     

    ALTER TABLE [HBTrigger_job_SearchKey] WITH NOCHECK ADD  CONSTRAINT [PK_HBTrigger_job_SearchKey] PRIMARY KEY  NONCLUSTERED ( [Serial] )

    SET IDENTITY_INSERT [HBTrigger_job_SearchKey] ON

    2、在job_SearchKey 创建修改 删除 触发器

    修改触发器:

    create Trigger [dbo].[HBTrigger_job_SearchKey_Update]
        On [dbo].[job_SearchKey]                        
        for Update                         
    
        As                                       
        DECLARE @updateFields nvarchar(4000)
        set @updateFields = ''
    
        if Update(keyid)          
        begin
        set @updateFields = @updateFields + 'keyid,'
        end       
    
        if Update(keyword)          
        begin
        set @updateFields = @updateFields + 'keyword,'
        end       
    
        if Update([Count])          
        begin
        set @updateFields = @updateFields + 'Count,'
        end       
    
        if Update(type)          
        begin
        set @updateFields = @updateFields + 'type,'
        end       
    
        if Update(addTime)          
        begin
        set @updateFields = @updateFields + 'addTime,'
        end   
         if Update(upTime)          
        begin
        set @updateFields = @updateFields + 'upTime,'
        end   
         if Update(RecordCount)          
        begin
        set @updateFields = @updateFields + 'RecordCount,'
        end   
    
        if @updateFields <> ''
        begin
        insert into HBTrigger_job_SearchKey select keyid, 'Update',  @updateFields from Inserted
    end
    

    删除触发器

    create Trigger [dbo].[HBTrigger_job_SearchKey_Delete]
     
    On [dbo].[job_SearchKey]
     
    for Delete
     
    As
     
    insert into HBTrigger_job_SearchKey select keyid, 'Delete', '' from Deleted
    

    注:插入操作不用添加触发器hubbledotnet会自动处理

    3、打开hubbledotnet(Query Analyzer) 在job_SearchKey右键选择Table InfoàAttributes

             TableSynchronization设置为true,TriggerTableName 添写第一步创建的触发器表名

    4、打开hubbledotnet(Query Analyzer)点击Managerment菜单 选择

    Task scheduler managerment 点击Add

    exec SP_SynchronizeTable 'job_SearchKey', 5000, 2 是hubbledotnet固定

    文章地址:http://www.cnblogs.com/eaglet/archive/2011/03/02/1969219.html

  • 相关阅读:
    tcp 粘包 和 TCP_NODELAY 学习
    分解抓取的包文件代码实现学习
    谨慎使用多线程中的fork 学习!!!!
    面试题
    Java并发编程:Lock
    为什么匿名内部类参数必须为final类型
    sql 面试题
    java hashCode方法返回值
    数组初始化
    Java内存模型
  • 原文地址:https://www.cnblogs.com/freexiaoyu/p/2059867.html
Copyright © 2011-2022 走看看