欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

如何为Windows安装和配置Azure Data Studio

程序员文章站 2022-03-13 21:19:13
...

Azure Data Studio is free, lightweight database development and operations cross-platform tool for private and commercial usage, that can be installed on Windows, macOS, and Linux for SQL Server, Azure SQL Database and Azure SQL Data Warehouse.

Azure Data Studio是免费的,轻量级的数据库开发和操作跨平台工具,用于私人和商业用途,可以安装在Windows,macOS和Linux上,用于SQL Server,Azure SQL数据库和Azure SQL数据仓库。

Azure Data Studio is built to simplify work of database developers, database administrators, and system administrators. Azure Data Studio boosts your productivity with smart code snippets, keyword completion, IntelliSense, source control integration, the ability to view and save results in CSV, Excel, JSON format, and the capability to organize and manage favorite database connections, etc. The first version of Azure Data Studio was released in November 2017.

Azure Data Studio旨在简化数据库开发人员,数据库管理员和系统管理员的工作。 Azure Data Studio通过智能代码段,关键字补全,IntelliSense,源代码控制集成,以CSV,Excel,JSON格式查看和保存结果的功能以及组织和管理常用数据库连接的功能等,从而提高了您的生产力。版本的Azure Data Studio于201711月发布。

The latest version of Azure Data Studio for all three platforms can be downloaded from the Download and install Azure Data Studio (preview) page.

可以从“ 下载并安装Azure Data Studio(预览)”页面下载适用于所有三个平台的最新版本的Azure Data Studio。

In this article, Azure Data Studio for Windows platform will be explained.

在本文中,将解释Windows平台的Azure Data Studio。

Azure Data Studio can be installed using the installer or .zip file for Windows

可以使用Windows的安装程序或.zip文件安装Azure Data Studio

The installation process is simple. Run installer and the Welcome window will appear, press the Next button to prosed:

安装过程很简单。 运行安装程序,将出现“欢迎”窗口,按下一步按钮进行处理:

如何为Windows安装和配置Azure Data Studio

On the License Agreement, select the ”I accept the agreement” radio button and press the Next button:

在许可协议上,选择“我接受协议”单选按钮,然后按下一步按钮:

如何为Windows安装和配置Azure Data Studio

On this window, choose where Azure Data Studio will be installed. Press the Next button to continue:

在此窗口上,选择Azure Data Studio的安装位置。 按下一步按钮继续:

如何为Windows安装和配置Azure Data Studio

Press the Next button, go all down to the last window where the Finish button should be pressed to exit from the Setup process:

按“下一步”按钮,向下进入最后一个窗口,在该窗口中应按“完成”按钮退出设置过程:

如何为Windows安装和配置Azure Data Studio

If the .zip file is used for installation of Azure Data Studio, unzip the sqlops-windows folder first, under the sqlops-windows folder, find and double-click sqlops.exe to run it:

如果.zip文件用于安装Azure Data Studio,请首先将sqlops-windows文件夹解压缩,在sqlops-windows文件夹下,找到并双击sqlops.exe来运行它:

如何为Windows安装和配置Azure Data Studio

This will open the Azure Data Studio window. In the Server box, type the name of the instance for which want to establish connection and press the Connect button. Unlike SSMS, this tool does not provide dropdown list of available databases for the connected server:

这将打开Azure Data Studio窗口。 在“ 服务器”框中,键入要为其建立连接的实例的名称,然后按“ 连接”按钮。 与SSMS不同,此工具不提供所连接服务器的可用数据库的下拉列表:

如何为Windows安装和配置Azure Data Studio

If the connection window does not appear when Azure Data Studio window is opened, simply click on the New Connection button:

如果在打开Azure Data Studio窗口时未显示连接窗口,只需单击“新建连接”按钮:

如何为Windows安装和配置Azure Data Studio

Once the connection information was provided in the window, something like this should appear:

在窗口中提供了连接信息后,将出现以下内容:

如何为Windows安装和配置Azure Data Studio

The Server pane is similar to Object Explorer in SQL Server Management Studio. This pane provides a way to navigate to the different objects in SQL Server:

“服务器”窗格类似于SQL Server Management Studio中的“对象资源管理器”。 此窗格提供了一种导航到SQL Server中不同对象的方法:

如何为Windows安装和配置Azure Data Studio

On the right side of the SQL plane is the Azure Data Studio dashboard which shows plenty useful information.

SQL平面的右侧是Azure Data Studio仪表板,其中显示了大量有用的信息。

In case dashboard does not appear, go to Servers pane, right-click and, from the context menu, select the Manage command:

如果未出现仪表板,请转到“服务器”窗格,右键单击,然后从上下文菜单中选择“管理”命令:

如何为Windows安装和配置Azure Data Studio

In the dashboard header, information about connected instance of SQL Server like version, edition, computer name, operating system version are shown:

在仪表板标题中,显示了有关SQL Server连接实例的信息,例如版本,版本,计算机名称,操作系统版本:

如何为Windows安装和配置Azure Data Studio

Under the SQL Server version, there are shortcuts to common tasks at server level: restore databases, configuration server and creating a new query:

在SQL Server版本下,在服务器级别有一些常见任务的快捷方式:还原数据库,配置服务器和创建新查询:

如何为Windows安装和配置Azure Data Studio

Next pane is the Backup Status pane, here, the backup status of the databases is shown:

下一个窗格是“备份状态”窗格,此处显示数据库的备份状态:

如何为Windows安装和配置Azure Data Studio

Right of the Backup Status pane, there is a search pane which provides a quick way to find a variety of objects on connected server:

在“备份状态”窗格的右侧,有一个搜索窗格,它提供了一种快速的方法来查找已连接服务器上的各种对象:

如何为Windows安装和配置Azure Data Studio

The last pane shows the sizes of the databases on a connected server:

最后一个窗格显示已连接服务器上数据库的大小:

如何为Windows安装和配置Azure Data Studio

On the left side of the Azure Data Studio, there are six icons:

在Azure Data Studio的左侧,有六个图标:

如何为Windows安装和配置Azure Data Studio

The first button is to bring up the Servers pane:

第一个按钮是调出“服务器”窗格:

如何为Windows安装和配置Azure Data Studio

The button below the Server button is the Task History button. In the Task History pane will be shown any backups, restores, or other similar tasks that were performed:

服务器按钮下面的按钮是任务历史记录按钮。 在“任务历史记录”窗格中,将显示已执行的所有备份,还原或其他类似任务:

如何为Windows安装和配置Azure Data Studio

Under the Explorer pane, the list of all opened files in Azure Data Studio are located:

在“资源管理器”窗格下,找到Azure Data Studio中所有打开的文件的列表:

如何为Windows安装和配置Azure Data Studio

Right-click on the file will show a context menu with useful options. The Open to the Side option opens the file in the split screen, providing the ability to compare two files side by side:

右键单击该文件将显示一个包含有用选项的上下文菜单。 “ 打开到侧面”选项在拆分屏幕中打开文件,提供并排比较两个文件的功能:

如何为Windows安装和配置Azure Data Studio

The Reveal in Terminal option opens a location of the file:

在终端中显示选项将打开文件的位置:

如何为Windows安装和配置Azure Data Studio

The Open in Terminal opens a terminal window in the lower side of the Azure Data Studio window:

在终端中打开”将在Azure Data Studio窗口的下部打开一个终端窗口:

如何为Windows安装和配置Azure Data Studio

By default, the PowerShell terminal is set. Also, it can be changed to Command Prompt (CMD), or a BASH terminal by clicking the Customize button and from the list, choose the desired terminal:

默认情况下,将设置PowerShell终端。 另外,可以通过单击“ 自定义”按钮将其更改为“命令提示符”(CMD)或BASH终端,然后从列表中选择所需的终端:

如何为Windows安装和配置Azure Data Studio

Another way to initiate the terminal is by pressing the Ctrl + ` (backtick character) keyboard shortcut, or using Ctrl + Shift + P keyboard combination to initiate the Command Palette and from there, choose the View:Toggle Integrated Terminal command:

启动终端的另一种方法是按Ctrl +`(反引号字符)键盘快捷键,或使用Ctrl + Shift + P键盘组合来启动命令面板,然后从中选择View:Toggle Integrated Terminal命令:

如何为Windows安装和配置Azure Data Studio

Multiple terminals can be opened in SQL Operation Studio by pressing “Ctrl + Shift + ` keyboard combination or by pressing the plus icon on the terminal:

可以通过按“ Ctrl + Shift +`键盘组合”或按终端上的加号图标来在SQL Operation Studio中打开多个终端:

如何为Windows安装和配置Azure Data Studio

To switch between opened terminals, use the drop-down list:

要在打开的终端之间切换,请使用下拉列表:

如何为Windows安装和配置Azure Data Studio

More about the Azure Data Studio terminals can be found on the Integrated Terminal page.

可以在“ 集成终端”页面上找到有关Azure Data Studio终端的更多信息。

Under the Explorer icon is the Search icon which brings the Search pane for search or search and replace text in the files:

在“资源管理器”图标下面是“搜索”图标,该图标将显示“搜索”窗格以进行搜索或搜索并替换文件中的文本:

如何为Windows安装和配置Azure Data Studio

The Source Control pane allows managing files with the source code control system. Azure Data Studio supports Git for version/source control. In order to use this feature, the Git needs to be installed first:

Source Control窗格允许使用源代码控制系统管理文件。 Azure Data Studio支持使用Git进行版本/源代码控制。 为了使用此功能,需要首先安装Git

如何为Windows安装和配置Azure Data Studio

Otherwise, the Source Control tab will look like this:

否则,“源代码管理”选项卡将如下所示:

如何为Windows安装和配置Azure Data Studio

More about source control feature can be found on the Using source control in Azure Data Studio (preview) page.

有关源代码管理功能的更多信息,请参见在Azure Data Studio中使用源代码管理(预览)页。

The last icon is the Settings icon. These options allow to set different settings of SQL Options Server like color theme, keyboard shortcuts and more:

最后一个图标是“设置”图标。 这些选项允许设置SQL Options Server的不同设置,例如颜色主题,键盘快捷键等:

如何为Windows安装和配置Azure Data Studio

Also, some of these options can be found under the Preferences sub-menu:

另外,其中一些选项可以在“ 首选项”子菜单中找到:

如何为Windows安装和配置Azure Data Studio

Almost every part of Azure Data Studio can be modified trough the User Settings options. To open settings, right click on the Settings icon and from context menu, choose the Settings command:

可以通过“ 用户设置”选项来修改Azure Data Studio的几乎每个部分。 要打开设置,请右键单击“设置”图标,然后从上下文菜单中选择“ 设置”命令:

如何为Windows安装和配置Azure Data Studio

Or use the keyboard shortcut (Ctrl+,). Another way to open settings is by using the Command Palette (Ctrl+Shift+P) and find Preferences: Open User Settings:

或使用键盘快捷键( Ctrl +, )。 另一种打开设置的方法是使用命令面板Ctrl + Shift + P )并找到“首选项”:打开用户设置:

如何为Windows安装和配置Azure Data Studio

Under the list, choose which option you want to modify (e.g. Disabling the Update option), expend the Update configuration, click on Edit button next to the option that want to modify and, from the context menu, choose desired option:

在列表下,选择要修改的选项(例如,禁用更新选项),扩展更新配置,单击要修改的选项旁边的编辑按钮,然后从上下文菜单中选择所需的选项:

如何为Windows安装和配置Azure Data Studio

Once the option is chosen, the information box will appear, suggesting to restart Azure Data Studio in order to changes take effect:

选择该选项后,将出现信息框,建议重新启动Azure Data Studio以使更改生效:

如何为Windows安装和配置Azure Data Studio

After restarting, the changes will be updated and the Update option will be disabled:

重新启动后,更改将被更新,并且“更新”选项将被禁用:

如何为Windows安装和配置Azure Data Studio

All options are saved in the settings.json file. Depending on which platform (Windows, Mac, Linux) Azure Data Studio is installed, location of the settings.json file is different. For Windows, this file is located under this path: %APPDATA%\sqlops\User\settings.json.

所有选项都保存在settings.json文件中。 根据所安装的平台(Windows,Mac,Linux),Azure Data Studio的settings.json文件的位置不同。 对于Windows,此文件位于以下路径下: %APPDATA%\ sqlops \ User \ settings.json。

The Keyboard Shortcuts editor enables easy way to change, reset, add or remove keyboard shortcuts:

键盘快捷键编辑器提供了简单的方法来更改,重置,添加或删除键盘快捷键:

如何为Windows安装和配置Azure Data Studio

Azure Data Studio provides a number of color themes which can be used to set desired working environment.

Azure Data Studio提供了许多颜色主题,可用于设置所需的工作环境。

Click on the Settings button and, from the context menu, choose the Color Theme command:

单击设置按钮,然后从上下文菜单中选择颜色主题命令:

如何为Windows安装和配置Azure Data Studio

From the dropdown list, pick a desired theme for example, Dark theme:

从下拉列表中选择所需的主题,例如,深色主题:

如何为Windows安装和配置Azure Data Studio

Azure Data Studio will look like this:

Azure Data Studio将如下所示:

如何为Windows安装和配置Azure Data Studio

Azure Data Studio has the ability to organize connection to the servers and databases in the separate groups and assign a color to the server groups.

Azure Data Studio能够组织到单独组中的服务器和数据库的连接,并为服务器组分配颜色。

To create a server group, press the New Server Group button at the top of the Servers pane:

要创建服务器组,请按“服务器”窗格顶部的“新建服务器组”按钮:

如何为Windows安装和配置Azure Data Studio

In the Server group name box, enter the name of the group and from the Group color pallet, choose a desired color for the group and press the OK button:

在“ 服务器组名称”框中,输入组的名称 ,然后从“ 组颜色”托盘中,为组选择所需的颜色,然后按“ 确定”按钮:

如何为Windows安装和配置Azure Data Studio

After pressing the OK button, the following error message may appear:

按确定按钮后,可能会出现以下错误信息:

如何为Windows安装和配置Azure Data Studio

This appears because the tab colors mode is by default turned off. To enable tab colors in the User Settings file find the sql.tabColorMode setting and from the context menu pick the “fill” command:

这是因为选项卡颜色模式默认情况下处于关闭状态。 要在用户设置文件中启用标签颜色,请找到sql.tabColorMode设置,然后从上下文菜单中选择“ fill”命令:

如何为Windows安装和配置Azure Data Studio

After enabling the tab colors mode, you will be available to create the server groups:

启用选项卡颜色模式后,您将可以创建服务器组:

如何为Windows安装和配置Azure Data Studio

The results from the Results grid can be saved as CSV, JSON or Excel file, by selecting data. From the context menu or from the icons next to the Results grid, choose the desired file format.

通过选择数据,结果网格中的结果可以另存为CSV,JSON或Excel文件。 从上下文菜单或“结果”网格旁边的图标中,选择所需的文件格式。

如何为Windows安装和配置Azure Data Studio

The last icon on the right side of the Results grid is the View as Chart icon:

“结果”网格右侧的最后一个图标是“ 以图表方式查看”图标:

如何为Windows安装和配置Azure Data Studio

On the right side of the Chart viewer, different chart types to displaying data can be set:

在“图表”查看器的右侧,可以设置与显示数据不同的图表类型:

如何为Windows安装和配置Azure Data Studio

To view the execution plan, press the Explain button. This option works the same as the execution plan viewer in SSMS:

要查看执行计划,请按Explain按钮。 此选项与SSMS中的执行计划查看器相同:

如何为Windows安装和配置Azure Data Studio

Azure Data Studio supports Query Store and provides nice way (widget) for displaying the slowest queries on the database dashboard. In a query editor, run the following T-SQL statement to enable Query Store:

Azure Data Studio支持查询存储,并提供了一种很好的方式(窗口小部件)在数据库仪表板上显示最慢的查询。 在查询编辑器中,运行以下T-SQL语句以启用查询存储

ALTER DATABASE AdventureWorks2014 SET QUERY_STORE = ON

ALTER DATABASE AdventureWorks2014 SET QUERY_STORE =开启

To add the insight widget for Query Store on the database dashboard, the dashboard.database.widgets setting under the User Settings file needs to be modified.

要在数据库仪表板上添加用于查询存储的见解小部件 ,需要修改用户设置文件下的dashboard.database.widgets设置。

Press the Ctrl + , (comma) keyboard shortcut to open the User Settings file. Find the dashboard.database.widgets setting, press the Edit (pencil) button and, from the context menu, press the Copy to Settings command:

Ctrl +(逗号)键盘快捷键打开“ 用户设置”文件。 找到仪表盘.database.widgets设置,按“ 编辑(铅笔)”按钮,然后从上下文菜单中按“ 复制到设置”命令:

如何为Windows安装和配置Azure Data Studio

This will copy setting to the right grid:

这会将设置复制到右侧网格:

如何为Windows安装和配置Azure Data Studio

Now, under the dashboard.database.widgets, add the curly braces:

现在,在dashboard.database.widgets下,添加 花括号

如何为Windows安装和配置Azure Data Studio

Type or paste the following code in the curly braces:

在花括号中输入或粘贴以下代码

“name”: “Slow queries”,
 
“gridItemConfig”: {
 
“sizex”: 2,
 
“sizey”: 1
 
},
 
“widget”: {
 
“query-data-store-db-insight”: null
 
}

Save the settings and open the database dashboard. The Slow queries widget appears on the dashboard:

保存设置并打开数据库仪表板。 慢查询小部件将显示在仪表板上:

如何为Windows安装和配置Azure Data Studio

To view additional information about slowest queries, on the right side of the Slow queries widget, press the ellipses (…) button and from the context menu, choose the Show Details command:

要查看有关最慢查询的其他信息,请在“慢查询”窗口小部件的右侧,按省略号(...)按钮,然后从上下文菜单中选择“ 显示详细信息”命令:

如何为Windows安装和配置Azure Data Studio

This will open the Insights pane:

这将打开“ 见解”窗格:

如何为Windows安装和配置Azure Data Studio

In the same way, custom insight widgets can be created. More about custom insight widgets can be found on the Tutorial: Build a custom insight widget page.

以相同的方式,可以创建自定义洞察小部件。 有关自定义洞察小部件的更多信息,请参见教程:构建自定义洞察小部件页面。

While start typing in a query editor, the hint-list will appear narrowing down the suggestions for the typed word in the query editor:

在查询编辑器中开始输入时,提示列表将出现,以缩小查询编辑器中所键入单词的建议:

如何为Windows安装和配置Azure Data Studio

Azure Data Studio provides T-SQL snippets which generate the proper T-SQL syntax to create stored procedures, tables, views, databases etc.

Azure Data Studio提供了T-SQL代码段 ,这些代码生成适当的T-SQL语法以创建存储过程,表,视图,数据库等。

In a query editor, type sql:

如何为Windows安装和配置Azure Data Studio

在查询编辑器中,输入sql

From the list, choose the desired T-SQL snippet (sqlAddColumn):

从列表中,选择所需的T-SQL代码段(sqlAddColumn):

如何为Windows安装和配置Azure Data Studio

Azure Data Studio allows creating custom T-SQL snippets. Azure Data Studio inherits code snippets functionality from Visual Studio Code. For more information of how to create T-SQL snippets in Azure Data Studio, visit the Creating your own snippets page.

Azure Data Studio允许创建自定义T-SQL代码段。 Azure Data Studio从Visual Studio Code继承了代码片段功能。 有关如何在Azure Data Studio中创建T-SQL代码段的更多信息,请访问“ 创建自己的代码段”页面。

翻译自: https://www.sqlshack.com/install-configure-azure-data-studio-windows/