Access文本字段上的唯一索引是否始终不区分大小写? [英] Are unique indices on Access text fields always case insensitive?

查看:63
本文介绍了Access文本字段上的唯一索引是否始终不区分大小写?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下代码创建了MS Access表:

I created an MS Access table using the following code:

  tbl := Database.CreateTableDef('English', 0, '', '');
  try
    fld := tbl.CreateField('ID', dbLong, 0);
    fld.Attributes := dbAutoIncrField + dbFixedField;
    tbl.Fields.Append(fld);

    fld := tbl.CreateField('Content', dbText, 255);
    fld.Required := true;
    fld.AllowZeroLength := false;
    tbl.Fields.Append(fld);

    Database.TableDefs.Append(tbl);

    idx := tbl.CreateIndex('PrimaryKey');
    idx.Fields.Append(idx.CreateField('ID', EmptyParam, EmptyParam));
    idx.Primary := True;
    idx.Unique := true;
    tbl.Indexes.Append(idx);

    idx := tbl.CreateIndex('IX_Content');
    idx.Fields.Append(idx.CreateField('Content', EmptyParam, EmptyParam));
    idx.Primary := false;
    idx.Unique := true;
    tbl.Indexes.Append(idx);
  finally
    tbl := nil;
  end;

这很好,直到我尝试将两个字符串字段类型"和字段类型"插入此表中.我收到一条错误消息,告诉我唯一索引限制了我执行此操作.如您所见,它们仅在第二个单词的情况下有所不同.由于我没有明确使索引不区分大小写(我什至不知道该怎么做),所以我不太明白为什么会这样.在MS Access中,文本字段的索引是否始终不区分大小写?如果没有,我在做什么错了?

This works fine until I try to insert the two strings 'Field type' and 'Field Type' into this table. I get an error telling me that the unique index restricts me from doing that. As you can see they only differ in the case of the second word. Since I did not explicitly make the index case insensitive (I wouldn't even know how to do that), I don't quite understand why this happens. Are indices on text fields always case insensitive in MS Access? If not, what am I doing wrong?

推荐答案

Access Jet数据库从根本上不区分大小写.那是你的问题.据我所知,没有办法使Access索引区分大小写.

Access Jet databases are fundamentally case insensitive. That is your problem. As far as I know there is no way to make an Access index case sensitive.

这篇关于Access文本字段上的唯一索引是否始终不区分大小写?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆