创建一个空表

表是用于保存数据的命名实体。 表具有一组有序列以及零个或零个以上的数据行。 每一行为表的每个列保存一个数据值。 表中的行顺序是未知的,除了某些本身不确定的表格运算符(例如 top 运算符)外,一般不会影响查询。

可以创建一个没有数据源的空表,用作测试环境,或用于在以后的阶段引入数据。 本文介绍如何在 KQL 数据库的上下文中创建空表。

先决条件

在 KQL 数据库中创建空表

  1. 浏览到所需的 KQL 数据库。

  2. 选择“+新建>”。

    Screenshot of lower ribbon that shows the dropdown menu of the New button in Real-Time analytics. The dropdown option titled Table is highlighted.

  3. 输入表的名称。

    Screenshot of the Destination tab in the new table wizard in Real-Time Analytics. The table name is highlighted.

    注意

    表名称最多可包含 1024 个字符,包括字母数字、连字符和下划线。 不支持特殊字符。

  4. 选择“下一步: 源”。

  1. 默认情况下,“源类型”设置为“”。 如果选择“”,则可以手动定义表架构。
  2. 选择“下一步: 架构”。

Screenshot of the Source tab that shows that the source type is set to None in the new table wizard in Real-Time Analytics.

架构

该工具会根据你的数据自动推断架构。 若要创建没有数据源的架构,则需要在“部分数据预览”下添加列。

命令查看器

命令查看器显示用于在表中创建表、映射和引入数据的命令。

若要打开命令查看器,请选择命令查看器右侧的 v 按钮。 在命令查看器中,可以查看和复制从输入生成的自动命令。

Screenshot of the Command viewer. The Expand button is highlighted.

部分数据预览

会根据数据自动推断部分数据预览。

若要添加新列,请选择“部分数据预览”下的“添加新列”。

Screenshot of the Schema tab in the new table wizard in Real-Time Analytics. The Add new column button is highlighted.

编辑列
  1. 输入列名。 列名称应以字母开头,可以包含数字、句点、连字符或下划线。

  2. 为列选择数据类型。 默认列类型为 string,但可以在“列类型”字段的下拉菜单中进行更改。

  3. 选择“添加列”以添加更多列。

  4. 选择“保存”,将列添加到表中。

    Screenshot of the Edit columns window showing filled column names and their data type in the new table wizard in Real-Time Analytics.

    部分数据预览反映了添加的列:

    Screenshot of Schema tab showing the added columns under the Partial data preview. The column names are highlighted.

    注意

    (可选)可以通过选择“编辑列”或“部分数据预览”下右侧列上的 + 按钮来编辑现有列并添加新列。

  5. 选择“下一步:摘要”以创建表映射。

“摘要”选项卡

在“创建表已完成”窗口中,空表带有绿色勾号,表示已成功创建。

Screenshot of the Summary tab that shows that the table was created successfully in Real-Time Analytics.