数据集 - 设置主键时,重复的值 [英] Dataset - duplicate values when setting primary key

查看:257
本文介绍了数据集 - 设置主键时,重复的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一栏person_ code的数据集。

I have a dataset with a column "person_code".

这列包含以下数据:

  • 在卡拉
  • 在卡拉 - >一个尾随空格

现在,如果我设置数据集的列的主键person_ code我会得到以下错误:

Now if i set the primary key of the dataset to the column "person_code" I'll get the following error:

这些列当前没有唯一值。

"These columns don't currently have unique values."

解决这个办法?最好我能想到的是添加一个新栏目primary_key,然后更换结束/开始另一个标志位。这将导致一些额外的问题:如果我代替他们_而且也已经是Carra_数据库...

Any way around this? The best I can think of is to add a new column "primary_key" and then replace the ending/starting spaces with another sign. This will cause some extra problems: if I replace them with _ and there's already a Carra_ in the database...

有没有更好的办法?

推荐答案

主键始终是唯一的,所以如果两个人有相同的人​​code,那么这确实会导致此问题

Primary keys are ALWAYS unique, so if two person have the same person code then this will indeed cause this problem

现在,他们似乎并不完全一致(就像你说的人有一个尾随的空间。我的猜测是,你的code可能会删除默认的尾部空间,你可能想要把一个符号在开始并在结束时,像卡拉和卡拉,使他们不同的。

Now, it seems that they are not entirely identical (as you say one has a trailing space. My guess is that your code may remove the trailing space by default. You might want to put a symbol at the start and at the end, like 'Carra' and 'Carra ' to make them different.

您可能需要尽管定义另一个symbole了这一点。尝试一个你知道的永远不会在你的数据。

You may need to define another symbole that that though. Try one that you know will never be in your data.

这篇关于数据集 - 设置主键时,重复的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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