简体   繁体   English

在 Kusto 表中添加唯一约束

[英]Adding unique constraint in Kusto tables

I have recently started working on Kusto, I am struggling to find out how we can add unique constraint in any kusto table as I used to do in Mysql.我最近开始研究 Kusto,我正在努力寻找如何在任何 kusto 表中添加唯一约束,就像我以前在 Mysql 中所做的那样。

Suppose I have created a table in kusto.假设我在 kusto 中创建了一个表。

.create table Mytable( Time:datetime, NoOfOperations: long);

If it was a sql table, I can easily define to add a unique key, I am unable to find out something k like this in kusto.如果它是一个 sql 表,我可以很容易地定义添加一个唯一的键,我无法在 kusto 中找到这样的东西。 Tried searching on kusto documents but couldn't find.尝试搜索 kusto 文档但找不到。

ALTER TABLE MyTable
ADD UNIQUE (Time);

Any help is highly appreciated..非常感谢任何帮助..

In Kusto, tables don't have the traditional primary/unique keys.在 Kusto 中,表没有传统的主键/唯一键。 To create a new table with unique Time values from the table MyTable , you could try the following:要从表MyTable创建一个具有唯一Time值的新表,您可以尝试以下操作:

.make-unique Mytable
| where Time != ""
| project Time

or you could use the summarize operator to group the data by Time and retrieve the first value:或者您可以使用summarize运算符按时间对数据进行分组并检索第一个值:

. summarize arg_min(Time, *) by Time
| project Time

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM