查询任务Query tasks


此功能目前以公共预览版提供。This feature is in Public Preview. 请联系 Azure Databricks 代表,以申请访问权限。Contact your Azure Databricks representative to request access.

创建查询Create a query

  1. 执行下列操作之一:Do one of the following:

    • 单击侧栏中的 创建图标 图标并选择“查询”。Click the Create Icon icon in the sidebar and select Query.
    • 单击侧栏中的 查询图标 图标,然后单击“+ 新建查询”按钮。Click the Queries Icon icon in the sidebar and click the + New Query button.

    此时会显示查询编辑器。The query editor displays.

  2. 在“新建查询”下面的框中,单击 向下箭头图标 图标,然后选择 SQL 终结点In the box below New Query, click the Down Arrow Icon icon and select a SQL endpoint. 若要筛选列表,请在文本框中输入文本。To filter the list, enter text in the text box.

    选择终结点Select endpoint

    第一次创建查询时,可用 SQL 终结点的列表按字母顺序显示。The first time you create a query the list of available SQL endpoints displays in alphabetical order. 下次创建查询时,将选择上次使用的 SQL 终结点。The next time you create a query, the last used SQL endpoint is selected.

    SQL 终结点旁的图标表示状态为:The icon next to the SQL endpoint indicates the status:

    • 运行Running 运行
    • 正在启动Starting 正在启动
    • 已停止Stopped 已停止


    如果没有 SQL 终结点,请与 SQL Analytics 管理员联系。If there are no SQL endpoints, contact your SQL Analytics administrator.

浏览数据对象Browse data objects

如果具有元数据读取权限,则架构浏览器会显示可用的数据库和表。If you have metadata read permission, the schema browser displays the available databases and tables.


如果没有数据对象,请与 SQL Analytics 管理员联系。If there are no data objects, contact your SQL Analytics administrator.

  1. 在 SQL 终结点下面的框中,单击In the box below a SQL endpoint, click the 向下箭头图标 图标,并选择一个数据库。icon and select a database.

    默认数据库Default database


    • 必须选择正在运行的 SQL 终结点。You must select a running SQL endpoint.
    • 为了在架构浏览器中查看数据对象,必须是数据对象所有者,或被授予了该对象的特权In order to see a data object in the schema browser, you must either be the data object owner or be granted privileges to the object.

    若要刷新架构,请单击To refresh the schema, click the 刷新架构图标 按钮。button.

    刷新架构Refresh schema

    可在搜索框中键入筛选器字符串来筛选架构:You can filter the schema by typing filter strings in the search box:

    筛选架构Filter schema

  2. 单击一个表来显示表中的列。Click a table to shows its columns.

    表列Table columns

构造查询Construct a query

可以通过从架构浏览器插入元素或在查询编辑器中键入内容来构造查询。You construct a query by inserting elements from the schema browser or typing in the query editor.

  • 在架构浏览器中,单击数据对象最右侧的双箭头。In the schema browser, click the double arrow on the far right of a data object.

    插入架构项Insert schema item

  • 在查询编辑器中键入内容。Type in the query editor.

    查询编辑器支持自动完成。The query editor supports autocomplete. 键入时,自动完成功能将建议有效的完成内容。As you type, autocomplete suggests valid completions. 例如,如果光标位置的有效完成内容是列,则自动完成功能将建议一个列名称。For example, if a valid completion at the cursor location is a column, autocomplete suggests a column name. 如果键入 select * from table as t where t.,则自动完成功能将识别出 ttable 的别名,并建议 table 中的列。If you type select * from table as t where t., autocomplete recognizes that t is an alias for table and suggests the columns inside table.

    自动完成别名Autocomplete alias

完成编辑后,单击“保存”。When you are done editing, click Save.

执行查询Execute a query

若要执行查询:To execute a query:

  1. 选择 SQL 终结点。Select a SQL endpoint.

  2. 在查询编辑器中指定一个查询。Specify a query in the query editor.

  3. 按 Ctrl/Cmd + Enter 或单击“执行”按钮 。Press Ctrl/Cmd + Enter or click the Execute button.

    执行查询Execute query


  • 如果终结点已停止,则你执行查询时终结点将启动。If an endpoint is stopped and you execute a query, the endpoint is started. 若要手动启动终结点,请按照启动终结点中的步骤操作。To manually start an endpoint, follow the steps in Start an endpoint.
  • “限制 1000”复选框已默认选中,以确保查询最多返回 1000 行。The Limit 1000 checkbox is selected by default to ensure that the query returns at most 1000 rows. 如果知道有更多的行,可取消选中此复选框,并在查询中指定 LIMIT 子句。If you know that there are more rows, you can unselect the checkbox and specify a LIMIT clause in your query.

查询结果将显示在“表”选项卡中。The query result displays in the Table tab.

执行查询结果Execute query result

刷新查询Refresh a query

如果查询有计划,则它会自动刷新。If your query has a schedule it will refresh automatically. 要在自动刷新间隙手动刷新查询,请单击“刷新”按钮。To manually refresh a query in between automatic refreshes, click the Refresh button.

刷新查询Refresh query

保存查询Save a query

若要保存查询,请按 Ctrl/Cmd + S 或单击“保存”按钮 。To save a query, press Ctrl/Cmd + S or click the Save button. 只有已保存的查询才会显示在查询列表中。Only saved queries display in the Queries list.

还原到已保存的查询Revert to a saved query

编辑查询时,“保存”按钮旁边会显示“还原”链接。When you edit a query, a Revert link displays next to the Save button.

“还原”链接Revert link

单击“还原”可以返回到已保存的版本。You can click Revert to go back to your saved version. 离开时,你的更改将保存到浏览器存储中,但是浏览器可能仍会显示有关丢失工作的警告。Your changes are persisted to browser storage when you leave, but the browser may still display warnings about losing work.

将查询移至回收站Move a query to Trash

若要将查询移至回收站,请单击查询编辑器右上方的垂直省略号 垂直省略号,然后选择“移至回收站”。To move a query to Trash, click the vertical ellipsis Vertical Ellipsis at the top-right of the query editor and select Move to Trash. 单击“移至回收站”进行确认。Confirm by clicking Move to Trash.

从回收站还原查询Restore a query from Trash

  1. 在“所有查询”列表中,单击In the All Queries list, click 回收站按钮..
  2. 单击查询。Click a query.
  3. 单击查询编辑器右上方的垂直省略号 垂直省略号,然后选择“还原”。Click the vertical ellipsis Vertical Ellipsis at the top-right of the query editor and select Restore.

永久删除查询Permanently delete a query

  1. 在“所有查询”列表中,单击In the All Queries list, click 回收站按钮..
  2. 单击查询。Click a query.
  3. 单击查询编辑器右上方的垂直省略号 垂直省略号,然后选择“删除”。Click the vertical ellipsis Vertical Ellipsis at the top-right of the query editor and select Delete.

复制查询Copy a query

若要创建查询副本(该查询由你或其他人创建),可为其创建分支。To create a copy of a query (created by you or someone else), you can fork it. 若要为查询创建分支,请单击查询编辑器右上方的垂直省略号 垂直省略号,然后选择“创建分支”:To fork a query, click the vertical ellipsis Vertical Ellipsis at the top-right of the query editor and select Fork:

为查询创建分支Fork query

下载查询结果Download a query result

可以将查询结果下载为 CSV、TSV 或 Excel 文件。You can download a query result as a CSV, TSV, or Excel file.

  1. 单击可视化效果下方的垂直省略号Click the vertical ellipsis 垂直省略号 按钮。button beneath the results pane.
  2. 选择“下载为 [CSV | TSV | Excel] 文件”。Select Download as [CSV | TSV | Excel] File.

下载查询结果Download query result

如果无法下载查询,则表示管理员已为 SQL Analytics 实例禁用了下载功能If you cannot download a query, your administrator has disabled download for your SQL Analytics instance.

查询编辑器工具Query editor tools

架构浏览器Schema browser

若要切换架构浏览器,请按 Alt/Option + D,或者单击架构浏览器和查询窗格之间的窗格句柄 窗格句柄To toggle the schema browser, press Alt/Option + D or click the pane handle Pane Handle between the schema browser and query pane.

自动完成Auto Complete

查询编辑器具有自动补全功能,可提高查询编写的速度。The query editor has Auto Complete, which makes writing queries faster. 自动补全功能可补全架构令牌、查询语法标识符(如 SELECTJOIN)和查询片段的标题。Auto Complete can complete schema tokens, query syntax identifiers (like SELECT and JOIN) and the titles of query snippets.

自动补全功能默认启用,除非你的数据库架构超过 5000 个令牌(表或列)。Auto Complete is enabled by default unless your database schema exceeds five thousand tokens (tables or columns).

  • 若要禁用自动补全功能,请按“Ctrl + 空格”,或者单击查询编辑器下方的 已启用自动补全 按钮:To disable Auto Complete, press Ctrl + Space or click the Auto Complete Enabled button beneath the query editor:
  • 若要启用自动补全功能,请按“Ctrl + 空格”,或者单击查询编辑器下方的 已禁用自动补全 按钮。To enable Auto Complete, press Ctrl + Space or click the Auto Complete Disabled button beneath the query editor.

配置查询权限Configure query permissions

若要配置可管理和运行查询的人员,请查看查询访问控制To configure who can manage and run queries, see Query access control.