Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何检查表是否具有唯一键?对于一个键列,它可以工作:
t:([k1:1 2 3]d:10 20 30); @[{update `u#k1 from t};`;{"Err: ",x}]
但是如何对多个键列做同样的事情呢?
t:([k1:1 2 2; k2:`a`b`b]d:10 20 30)
假设您正在寻找作为向量的唯一键值,以下应该可以工作,以下将给出布尔值是或否
t:([k1:1 2 2; k2:`a`b`b]d:10 20 30) {count[x]~count distinct x} flip value flip key t
如果您询问每个键列是否唯一,那么您可以执行以下操作
t:([k1:1 2 2; k2:`a`b`b]d:10 20 30) @[`u#;flip value flip key t;'"not unique"]