zoukankan      html  css  js  c++  java
  • sql 2005 全文检索

    Sql 2005 全文索引

    Northwind示例数据库

    操作其Customers

    --初始化全文索引

    EXEC sp_fulltext_database 'enable'

    GO

     

    --创建一个名为test 的全文目录

    EXEC sp_fulltext_catalog 'test', 'create'

    GO

     

    --创建并填充全文索引

    EXEC sp_fulltext_table 'Customers','create','test','PK_Customers'

    EXEC sp_fulltext_column 'Customers','CompanyName','add',0x0804

    EXEC sp_fulltext_table 'Customers','start_change_tracking'

    EXEC sp_fulltext_table 'Customers','Start_background_updateindex'

    GO

     

    WAITFOR DELAY '00:00:15'

    --延时后可以检索到数据

    SELECT * FROM Customers WHERE CONTAINS(CompanyName,N'La')

    SELECT * FROM Customers WHERE CONTAINS(CompanyName,N'Hungry')

    GO

     

    得到两个数据集

     

    再加一列

    EXEC sp_fulltext_column 'Customers','ContactName','add',0x0804

    EXEC sp_fulltext_table 'Customers','start_change_tracking'

    EXEC sp_fulltext_table 'Customers','Start_background_updateindex'

     

    再来搜索

    SELECT * FROM Customers WHERE CONTAINS(CompanyName,N'La')

    or CONTAINS(ContactName,N'Elizabeth')

     


    再加一个表

    试验:2005支持ntext查询

    select * from Employees where Notes like '%Steven%'

     

    EXEC sp_fulltext_table 'Employees','create','test','PK_Employees'

    EXEC sp_fulltext_column 'Employees','Notes','add',0x0804

    EXEC sp_fulltext_table 'Employees','start_change_tracking'

    EXEC sp_fulltext_table 'Employees','Start_background_updateindex'

    GO

    结果

    警告: 表或索引视图'Employees' 具有类型为imagetext ntext 的全文索引列。全文更改跟踪无法跟踪对这些列执行的WRITETEXT UPDATETEXT 操作。

    SELECT * FROM Employees WHERE CONTAINS(Notes,N'Steven')

     

     

  • 相关阅读:
    Luogu P1962 斐波那契数列
    Luogu P2370 yyy2015c01的U盘
    Luogu P2678跳石头
    POJ3111 K Best
    表单内容相关操作
    框架集与框架.
    spring aop的使用
    sql查询的优化(六)
    mysql数据库视图(五)
    mysql数据库索引(四)
  • 原文地址:https://www.cnblogs.com/huang/p/833712.html
Copyright © 2011-2022 走看看