Table.AddKey

Table.AddKey(table as table,  columns as list,  isPrimary as logical) as table

将一个键添加到 table,给定的 columns 是定义该键的 table 的列名称的子集,并且 isPrimary 指定该键是否为主键。

示例:

向包含 {"Id"} 的 {[Id = 1, Name = "Hello There"], [Id = 2, Name = "Good Bye"]} 添加键并使其成为主键。

使用情况:
let
    tableType = type table [Id = Int32.Type, Name = text],
    table = Table.FromRecords({[Id = 1, Name = "Hello There"], [Id = 2, Name = "Good Bye"]}),
    resultTable = Table.AddKey(table, {"Id"}, true)
in
    resultTable
输出:
Table.FromRecords({[Id = 1, Name = "Hello There"], [Id = 2, Name = "Good Bye"]}, {
    "Id",
    "Name"
})

results matching ""

    No results matching ""