SQL Ops Studio 內建了多個 Insight widgets(小工具)。
Insight widgets 是
- 可自訂圖表和圖形,可以加入到 伺服器和資料庫監視 Dashboard (儀表板)上來使用。
- 可以由 T-SQL 所組成。
- 能以 摘要資訊方式呈現,而且能 再展開並呈現深入的 詳細資訊。

[SQL Ops Studio] Enable built-in insight widgets - table space usage insight
- 使用 內建的 Insight widgets(小工具)
- 啟用 資料表空間使用量 Insight
安裝與啟用 內建的 資料表空間使用量 Insight widgets(小工具)
01. 按下鍵盤的組合鍵:Ctrl+Shift+P,在 Command Palette(命令選擇區),開啟 User Settings(使用者設定)。
02. 在 搜尋方塊 中,輸入 Settings,再選擇 Preferences: Open User Settings。
-- figure 11_Command Palette

03. 檢視已經 開啟的 User and Workspace Settings (使用者和工作區設定),這是用於 使用者設定和開啟工作區設定 的 喜好設定。
User settings file(使用者設定檔) - settings.json,預設的檔案位置:
- Windows: %APPDATA%\sqlops\User\settings.json
- Mac: $HOME/Library/Application Support/sqlops/User/settings.json
- Linux: $HOME/.config/sqlops/User/settings.json
Workspace setting file(工作區設定檔案)
- 位於: .[!INCLUDE[name-sos](../includes/name-sos-short.md)]專案資料夾中的。
-- figure 12_Preferences Open User Settings

04. 在 左邊 的 User Settings 的搜尋輸入方塊,輸入 dashboard。
- 在其下方 json 格式的 使用者設定檔,在 左邊的 DEFAULT SETTINGS 資料行區域,找到 dashboard.database.widgets 區段(section)。
-- figure 13_dashboard.database.widgets

05. 若是第一次設定,在 json 格式的 使用者設定檔內。
- 在右邊的 USER SETTINGS 資料行區域,預設是沒有 "dashboard.database.widgets" 區段(section)。
在 User settings file 中(使用者設定檔),可以分成以下區域來設定:
- 左 邊是 DEFAULT SETTINGS 資料行區域。
- 右 邊是 USER SETTINGS 資料行區域。
-- figure 14_no dashboard.database.widgets

06. 編輯設定 "dashboard.database.widget" 區段。
- 在 左邊 的 DEFAULT SETTINGS,使用 滑鼠 移動找到 dashboard.database.widgets 區段(section)。
- 在 左邊 會出現 pencil icon(鉛筆圖示),可以看到 Edit。
-- figure 15_pencil icon

07. 在 快顯示窗中,若出現 Copy to Settings,滑鼠點選此。
若出現 Replace in Settings,請取消點選。應該可以在 右邊的 USER SETTINGS 資料行區域找到 "dashboard.database.widgets" 區段(section)。
-- figure 16_Copy to Settings

08. 可以觀察到 dashboard.database.widgets 區段(section),已經複製到 右邊 的 USER SETTINGS 資料行區域。
-- figure 17_Copy to Settings

若出現 Replace in Settings,請取消 點選。
應該可以在 右邊的 USER SETTINGS 資料行區域找到 "dashboard.database.widgets" 區段(section)。
-- figure 18_Dont_Click_Replace in Settings

09. 檢視 "dashboard.database.widgets" 區段(section)。
-- figure 21_dashboard.database.widgets

10. 在 Dashboard.database.widgets 區段,加入以下資訊:
- 此為:啟用 內建的 資料表空間使用量 Insight widgets(小工具)
{ "name": "Space Used by Tables", "gridItemConfig": { "sizex": 2, "sizey": 1 }, "widget": { "table-space-db-insight": null } },
-- figure 22_JSON_Space Used by Tables

11. 檢視與確認: 啟用 內建的 資料表空間使用量 Insight widgets(小工具)
-- figure 23_Add_Space Used by Tables

12. 綜觀:User settings file(使用者設定檔) - settings.json。
- 右邊的 USER SETTINGS 資料行區域,已經加入 "dashboard.database.widgets" 區段(section) 以及 啟用 內建的 資料表空間使用量 Insight widgets(小工具)。
-- figure 24_Add_Space Used by Tables

13. 按下 鍵盤組合鍵:Ctrl + S,儲存先前的設定。
使用 內建的 資料表空間使用量 Insight widgets(小工具)
01. 在左邊的 SERVERS Sidebar,在 伺服器與資料庫管理的 Dashboard (儀表板)。
- 任選一個資料庫,例如:選擇 Northwind,滑鼠右鍵,選擇 Manage。
-- figure 31_click Manage

02. 檢視:內建的 資料表空間使用量 Insight widgets(小工具)。
-- figure 32_Space Used by Tables

03. 檢視:內建的 資料表空間使用量 Insight widgets(小工具)。
-- figure 33_Space Used by Tables

Insight widgets(小工具)的功能
內建的 資料表空間使用量 Insight widgets(小工具),提供了:
- 篩選 功能。
- 滑鼠停留時,顯示 詳細資料。
01. 滑鼠移動到 Products 資料表上,可以自動顯示出 詳細資料。
-- figure 34_mouse pointer over the chart.

02. 滑鼠點選 左上方 的 rows_count 圖例,將關閉與隱藏此資料數列。
-- figure 41_Disable_rows_count

03. 僅 開啟 rows_count 圖例,僅顯示 rows_count 資料數列。
-- figure 42_rows_count

04. 滑鼠移動到 Products 資料表上,自動顯示該 資料數列的標籤 以及其數值。
-- figure 43_rows_count

05. 在此 Insight widgets,點選 右上方的 省略符號 (...) 。
-- figure 51_Toggle_More

06. 點選 Run Query。
-- figure 52_Run_Query

07. 檢視:產生 詳細資料 用的 T-SQL。
-- figure 53_View_Query

References
Tutorial: Enable the table space usage sample insight widget using SQL Operations Studio (preview)
https://docs.microsoft.com/en-us/sql/sql-operations-studio/tutorial-table-space-sql-server?view=sql-server-2017
http://sharedderrick.blogspot.tw/2018/04/sqlops-sql-operations-studio.html
SQL Ops Studio: Connect and query SQL Server using SQL Ops Studio
http://sharedderrick.blogspot.tw/2018/04/sql-ops-connect-and-query-sql-server.html
SQL OPS: Server Group
http://sharedderrick.blogspot.tw/2018/04/sql-ops-server-group.html
SQL Ops Studio: Selecting the Color Theme - Dark theme
http://sharedderrick.blogspot.tw/2018/04/sql-ops-selecting-color-theme-dark-theme.html
SQL Ops Studio: Sidebar (資訊看板)
http://sharedderrick.blogspot.tw/2018/04/sql-ops-studio-sidebar.html