📄 35275.htm
字号:
<link href="./dzs_cs.css" rel="stylesheet" type="text/css" /><table width="96%" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td> </td> </tr> <tr> <td height="24" align="center" valign="bottom" class="d_font3">实例演示在SQL数据库中启用全文检索</td> </tr> <tr> <td height="3" bgcolor="#E3E3E3"></td> </tr> <tr> <td> </td> </tr> <tr> <td class="d_font4"><P>这是一个全文索引的一个例子,首先在查询分析器中使用:
<TABLE cellSpacing=0 borderColorDark=#ffffff cellPadding=2 width=400 align=center borderColorLight=black border=1>
<TBODY>
<TR>
<TD class=code bgColor=#e6e6e6><PRE>e pubs
go</PRE></TD></TR></TBODY></TABLE>
<P>打开数据库全文索引的支持
<TABLE cellSpacing=0 borderColorDark=#ffffff cellPadding=2 width=400 align=center borderColorLight=black border=1>
<TBODY>
<TR>
<TD class=code bgColor=#e6e6e6><PRE>ute sp_fulltext_database 'enable'
go</PRE></TD></TR></TBODY></TABLE>
<P>建立全文目录ft_titles
<TABLE cellSpacing=0 borderColorDark=#ffffff cellPadding=2 width=400 align=center borderColorLight=black border=1>
<TBODY>
<TR>
<TD class=code bgColor=#e6e6e6><PRE>ute sp_fulltext_catalog 'ft_titles', 'create'
go</PRE></TD></TR></TBODY></TABLE>
<P>为titles表建立全文索引数据元,UPKCL_titleidind是主键所建立的唯一索引,可由sp_help titles得知
<TABLE cellSpacing=0 borderColorDark=#ffffff cellPadding=2 width=400 align=center borderColorLight=black border=1>
<TBODY>
<TR>
<TD class=code bgColor=#e6e6e6><PRE>cute sp_fulltext_table 'titles','create', 'ft_titles', 'UPKCL_titleidind'
go</PRE></TD></TR></TBODY></TABLE>
<P>设置全文索引列名
<TABLE cellSpacing=0 borderColorDark=#ffffff cellPadding=2 width=400 align=center borderColorLight=black border=1>
<TBODY>
<TR>
<TD class=code bgColor=#e6e6e6><PRE> exec sp_fulltext_column 'titles', 'title', 'add'
go
exec sp_fulltext_column 'titles', 'notes', 'add'
go</PRE></TD></TR></TBODY></TABLE>
<P>建立全文索引
<TABLE cellSpacing=0 borderColorDark=#ffffff cellPadding=2 width=400 align=center borderColorLight=black border=1>
<TBODY>
<TR>
<TD class=code bgColor=#e6e6e6><PRE> exec sp_fulltext_table 'titles', 'activate'
go</PRE></TD></TR></TBODY></TABLE>
<P>填充全文索引目录
<P>
<TABLE cellSpacing=0 borderColorDark=#ffffff cellPadding=2 width=400 align=center borderColorLight=black border=1>
<TBODY>
<TR>
<TD class=code bgColor=#e6e6e6><PRE> exec sp_fulltext_catalog 'ft_titles', 'start_full'
go</PRE></TD></TR></TBODY></TABLE>
<P>使用contains和freetext
<TABLE cellSpacing=0 borderColorDark=#ffffff cellPadding=2 width=400 align=center borderColorLight=black border=1>
<TBODY>
<TR>
<TD class=code bgColor=#e6e6e6><PRE> select title, notes from titles
where contains(title, '"computer Cooking"')
go
select title, notes from titles
where freetext(title, 'computer Cooking')
go
select title, notes from titles
where freetext(title, '"computer Cooking"')
go
select title, notes from titles
where contains(title, 'computer')
go
select title, notes from titles
where freetext (*, 'computer')
go</PRE></TD></TR></TBODY></TABLE>
<P>(责任编辑:铭铭 <A href="mailto: mingming_ky@126.com">mingming_ky@126.com</A> TEL:(010)68476636)</P></td> </tr> <tr> <td class="d_font4"> </td> </tr> </table>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -