小编浅谈SQL全文本检索方法
启动全文本检索服务。
在企业管理器中打开 Support Services 文件夹,在 Full-Text Search 的右键菜单中选择 Start。
使用 SQL-DMO (以 VB 为例)
step1. 在工程的引用中选择 Microsoft SQLDMO Object Library。
step2. 创建 SQLServer 对象。
Dim objSQL As New SQLDMO.SQLServer
objSQL.Connect "localhost", "sa", ""
step3. 创建新的目录,并加入到被索引的数据库目录中。
Dim objCatalog As New SQLDMO.FullTextCatalog
'使 pubs 为全文本检索的数据库
objSQL.Databases("pubs").EnableFullTextCatalogs
'创建新的目录
objCatalog.Name = "ftcPubsTest"
'将新目录加入到目录集合中
objSQL.Databases("pubs").FullTextCatalogs.Add objCatalog
step4. 在表上创建全文本索引。
Dim objTable As New SQLDMO.Table
'指定被索引的表
Set objTable = objSQL.Databases("pubs").Tables("authors")
'指定目录名和唯一索引名
objTable.FullTextCatalogName = "ftcPubsTest"
objTable.UniqueIndexForFullText = "UPKCL_auidind"
objTable.FullTextIndex = True
'指定被索引的列
objTable.Columns("au_lname").FullTextIndex = True
objTable.Columns("au_fname").FullTextIndex = True
'激活该表上的全文本索引
objTable.FullTextIndexActive = True
step5. 启动全文本目录
objCatalog.Start SQLDMOFullText_Full
使用存储过程
step1. 使 pubs 为全文本检索的数据库
USE Pubs
go
sp_fulltext_database 'enable'
step2. 创建新的目录
sp_fulltext_catalog 'ftcPubsTest','create'
step3. 指定被索引的表
sp_fulltext_table 'authors','create','ftcPubsTest','UPKCL_auidind'
step4. 指定被索引的列
sp_fulltext_column 'authors','au_lname','add'
sp_fulltext_column 'authors','au_fname','add'
step5. 激活该表上的全文本索引
sp_fulltext_table 'authors','activate'
step6. 启动全文本目录
sp_fulltext_catalog 'ftcPubsTest','start_full'
我们通过例子来学习,假设有表 students,其中的 address
相关文档:
表:TABLEA
客户编号 应收金额 收款金额
1001 100 80
1001 200 180&nb ......
第二部分
1.所有男生的姓名、年龄:
Select Sname,Sage
from student;
2.所有年龄大于20,计算机科学系学生名单:
SELECT Sname
from Student
WHERE Sage>20 AND Sdept='CS';
3.成绩大于60的学生学号:
SELECT Sno
from SC
WHERE Grade>60;
4.成绩在70到80之间的学生学号:
SELECT Sno
from SC
......
1:应用程序不再需要使用 Class.forName() 显式地加载 JDBC 驱动程序。当前使用 Class.forName() 加载 JDBC 驱动程序的现有程序将在不作修改的情况下继续工作。
2:需要注意以下命令:
executeUpdate:是最基础的数据库的更新、插入和删除操作。效率低下。
executeQuery:是最基础的执行查询语句,同样 ......
数据库sql语句系列都是以下面的表为基础的
1. 写出步骤4中的各项操作的SQL语句。
① 给学生表增加一属性Nation(民族),数据类型为Varchar(20);
alter table Student add Nation varchar(20);
② 删除学生表中新增的属性Nation;
alter table Student DR ......