Type.ReplaceTableKeys
傳回新的資料表類型,並以指定的索引鍵清單取代所有所有索引鍵。
Syntax
Type.ReplaceTableKeys(
tableType as type,
keys as list
) as type
Remarks
傳回以指定的索引鍵清單取代所有索引鍵的新資料表類型。
每個索引鍵都是使用下列格式的記錄來定義:
Columns: 定義索引鍵的資料行名稱清單Primary: 如果索引鍵是資料表的主索引鍵,則為true; 否則為false
指定的索引鍵清單會經過驗證,以確保只定義一個主索引鍵,而且資料表類型有所有索引鍵資料行名稱。
Examples
Example #1
取代資料表類型的索引鍵資訊。
let
BaseType = type table [ID = number, FirstName = text, LastName = text],
KeysAdded = Type.ReplaceTableKeys(
BaseType,
{
[Columns = {"ID"}, Primary = true],
[Columns = {"FirstName", "LastName"}, Primary = false]
}
),
DetailsOfKeys = Type.TableKeys(KeysAdded)
in
DetailsOfKeys
Result:
{
[Columns = {"ID"}, Primary = true],
[Columns = {"FirstName", "LastName"}, Primary = false]
}
Example #2
清除先前為資料表類型定義的索引鍵資訊。
let
TypeWithKey = Type.AddTableKey(type table [ID = number, Name = text], {"ID"}, true),
KeyRemoved = Type.ReplaceTableKeys(TypeWithKey, {}),
DetailsOfKeys = Type.TableKeys(KeyRemoved)
in
DetailsOfKeys
Result:
{}
Category
Type