> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Insights 管理命令

> PlayFab Insights 管理和資料控制 Kusto 命令的參考，可用於檢查查詢、變更保留、建立自訂資料表，以及擷取或清除資料。

Insights 管理命令可讓使用者對其資料系統進行更多控制，或收集更多相關資訊。這些命令分為兩個主要類別：

1. 管理 - 這些命令可讓使用者檢視更多關於查詢、命令、保留的資訊，以及變更保留
2. 資料控制 - 這些命令可讓使用者建立和卸除自訂資料表、擷取本機和雲端資料，以及從其資料庫清除資料

<Note>
  PlayFab Insights Management 將於 2026/3/31 淘汰。我們建議日後使用 [Data Connections](/zh-TW/services/playfab/data-analytics/export-data/data-connection-adx) 來管理您的效能和成本。如果您的遊戲仍在使用 **Insights**，請繼續參閱本文以了解最佳做法詳細資料。如需詳細資訊，請參閱 [Insights 淘汰部落格](https://developer.microsoft.com/en-us/games/articles/2025/11/playfab-insights-management-getplayerinsegment-apis-retired-starting-march-31/)。
</Note>

部分命令在評估模式中無法使用。

| 類別 | 命令 |
| - | - |
| 管理 | .show queries<br />.show running queries<br />.show commands-and-queries<br />.show table policy retention<br />.alter table policy retention |
| 資料控制 | .create table<br />.drop table<br />.set<br />.append<br />.set-or-append<br />.set-or-replace<br />.ingest into table<br />.purge table |

## 管理

**.show queries**
傳回由使用者、其他使用者或所有使用者目前正在執行的查詢清單。
使用方式：`.show  queries`
範例：`.show queries | where StartedOn > ago(1d)`
此命令會顯示過去一天內執行的所有查詢
**.show running queries**
顯示所有目前正在執行的查詢
使用方式：`.show running queries`
範例：`.show running queries`
此命令會顯示所有目前正在執行的查詢。
**.show database policy caching**
顯示資料庫目前的快取原則
使用方式：`.show database DatabaseName policy caching`
範例：`.show database myDatabase policy caching`
此命令會顯示指定資料庫目前的快取原則。
**.show table policy caching**
顯示資料表目前的快取原則
使用方式：`.show database DatabaseName.TableName policy caching`
範例：`.show database myDatabase.myTable policy caching`
此命令會顯示指定資料表目前的快取原則。
**.show commands-and-queries**
傳回包含已達到最終狀態之管理命令和查詢的資料表。這些命令和查詢可在 30 天內供查詢。
使用方式：`.show commands-and-queries`
範例：`.show commands-and-queries | where StartedOn > ago(1d) | where State != "Completed"`
此命令會顯示過去一天內失敗的所有命令和查詢
**.show table policy retention**
顯示資料表的有效保留原則，並將叢集和資料庫規則納入考量
使用方式：`.show table(s) (<table_name> [, ...]) policy retention`
範例：`.show table ['events.all'] policy retention`
此命令會顯示 "events.all" 資料表目前的保留原則。

**.alter table policy retention** (僅限採用耗用量定價模式的帳戶)
將一或多個資料表目前的保留原則變更為 \<retention\_policy>
使用方式：`.alter tables (<table_name> [, ...]) policy retention <retention_policy>`
範例：`.alter table ['events.all'] policy retention softdelete = 90d`
此命令會設定 "events.all" 資料表中的資料在 90 天後從資料表中移除。

## 資料控制

**.create table** (僅限效能等級 2 及以上)
建立新的空白資料表。此命令必須在特定資料庫的內容中執行。如果資料表已存在，命令會傳回成功。
使用方式：`.create table TableName ([columnName:columnType], ...)`
範例：`.create table ['custom.logs'] (Level:string, Timestamp:datetime, Id:string, Message:string)`
此命令會建立名為 "custom.logs" 且有四個資料行的新資料表。**重要：自訂資料表必須以 "custom." 開頭。**

**.drop table** (僅限效能等級 2 及以上)
卸除指定的資料表。注意：此動作無法復原。
使用方式：`.drop table TableName [ifexists]`
範例：`.drop table ['custom.logs']`
此命令會卸除名為 "custom.logs" 的資料表。

**.set** (僅限效能等級 2 及以上)
以查詢或命令的結果建立資料表
使用方式：`.set  TableName [with (PropertyName = PropertyValue [, ...])] <| QueryOrCommand`
範例：`.set [‘custom.recentEvents’] <| [‘events.all’] | where Timestamp > now() – time(1h)`
此命令會建立包含上述查詢結果的資料表 "custom.recentEvents"

**.append** (僅限效能等級 2 及以上)
將 QueryOrCommand 的結果附加到現有資料表
使用方式：`.append  TableName [with (PropertyName = PropertyValue [, ...])] <| QueryOrCommand`
範例：`.append [‘custom.recentEvents’] <| [‘events.all’] | where Timestamp > now() – time(1h)`
此命令會將上述查詢的結果新增至現有資料表 "custom.recentEvents"

**.set-or-append** (僅限效能等級 2 及以上)
以 QueryOrCommand 的結果建立資料表或附加至資料表
使用方式：`.set-or-append  TableName [with (PropertyName = PropertyValue [, ...])] <| QueryOrCommand`
範例：`.set-or-append [‘custom.weekEvents’] <| [‘events.all’] | where Timestamp > now() – time(7d)`
此命令會將上述查詢的資料附加至資料表 "custom.weekEvents"。如果資料表不存在，則會建立它。

**.set-or-replace** (僅限效能等級 2 及以上)
如果資料表存在，則取代其資料 (卸除現有的資料分區)；如果目標資料表尚不存在，則建立它。除非 extend\_schema 或 recreate\_schema 其中一個擷取屬性設定為 true，否則會保留資料表結構描述。如果結構描述有所修改，修改會在實際資料擷取之前於其自身的交易中進行，因此資料擷取失敗並不表示結構描述未被修改。
使用方式：`.set-or-replace  TableName [with (PropertyName = PropertyValue [, ...])] <| QueryOrCommand`
範例：`.set-or-replace [‘custom.dayEvents’] <| [‘events.all’] | where Timestamp > now() – time(1d)`
此命令會以上述查詢取代資料表 "custom.dayEvents" 中的資料。

**.ingest into** (僅限效能等級 2 及以上)
從一或多個雲端儲存體成品「提取」資料，將資料擷取至資料表。
使用方式：`.ingest  into table TableName SourceDataLocator [with ( IngestionPropertyName = IngestionPropertyValue [, ...] )]`
範例：`.ingest into table [‘custom.myData’] (h’<your url here>’) with(ignoreFirstRecord=true)`
此命令會從 URL 中所列的雲端儲存體將資料推送至資料表 "custom.myData"。

**.purge table** (僅限效能等級 2 及以上)
從資料庫永久刪除資料表中的資料
使用方式：`.purge table [TableName] in database [DatabaseName] allrecords with (noregrets='true')`
範例：`.purge table [‘custom.toPurge’] in database MyDatabase allrecords`
此命令會清除資料表 "custom.toPurge" 中的所有資料，將其從您的資料系統中永久刪除。


## Related topics

- [Insights 最佳做法](/zh-TW/services/playfab/data-analytics/legacy/insights/best-practices.md)
- [Insights](/zh-TW/services/playfab/data-analytics/legacy/insights/overview.md)
- [為 PlayFab Insights 建立 Microsoft Entra ID 應用程式](/zh-TW/services/playfab/data-analytics/legacy/connectivity/creating-AAD-app-for-insights.md)
- [效能與保留](/zh-TW/services/playfab/data-analytics/legacy/insights/performance-retention.md)
- [GDK 名詞與縮寫詞彙表](/zh-TW/home/glossary.md)
