A view is a virtual table based on the result set of a SQL query. It doesn’t store data; the data is dynamically retrieved from underlying tables.
Database Explorer allows you to perform operations on views using the shortcut menu. Right-click a view in Database Explorer to access options for specific tasks, such as creating or editing a view, or exporting or importing data.
1. In Database Explorer, right-click a view or the Views node and select New View.
2. In View Editor, specify the view details:
3. At the bottom of View Editor, click Apply Changes to save the view.
1. In Database Explorer, right-click the view you want to edit and select Open Editor.
2. In View Editor, update the view details.
Note
View Editor doesn’t support changing the view schema. This action requires moving the view to a different schema, rather than modifying its structure.
3. At the bottom of View Editor, select Apply Changes to apply the changes.
1. In Database Explorer, right-click the view you want to edit and select Modify via SQL.
2. In a SQL document, edit the view.
3. On the SQL toolbar, click Save to save the changes.
Alternatively, in the top menu, select File > Save, or press Ctrl+S.
1. In Database Explorer, right-click the view you want to delete and select Delete, or press Delete.
2. Click Yes to confirm the deletion.
Note
You cannot undo the drop view operation, as this action permanently deletes all its data and structure. It is recommended that you back up the database before deleting it.
1. In Database Explorer, right-click a required view and select Duplicate Object.
2. In the Duplicate Object dialog, configure the object settings:
3. Click OK.
1. In Database Explorer, right-click the view and select Open Data in Editor.
Alternatively, select Open Editor and switch to the Data tab.
2. On the Data tab of View Editor, view the data in the grid.
3. To perform any action on the data, right-click the selected row and select the required command from the shortcut menu.
For more information, see Work with data in Data Editor.
To retrieve data from the selected view, in Database Explorer, right-click it and select Select All Rows.
1. In Database Explorer, right-click the selected view and select Rename.
2. Specify the new view name, then press Enter.
The following table describes the shortcut menu options, which appear when you right-click a specific view in Database Explorer.
| Name | Description |
|---|---|
| New View | Opens View Editor to create and manage a view. |
| Modify via SQL | Opens a SQL document to edit a view using SQL. |
| Open Editor | Opens View Editor to edit a view. |
| Open Data in Editor | Opens the Data tab of View Editor to view and manage view data. |
| Select All Rows | Retrieves data from the selected view. |
| Manage Index Fragmentation | Opens the Index Manager document to analyze SQL indexes by collecting index fragmentation statistics and detecting databases that require maintenance. |
| Source Control > Source Control Manager | Opens Source Control Manager, where you can track and manage changes to database schema and static data. When Source Control Manager is already open, this option refreshes it. |
| Source Control > Commit | Opens Source Control Manager with all local changes (if any) selected and ready to commit. When Source Control Manager is already open, this option refreshes it and selects all local database changes. |
| Source Control > Get Latest | Opens Source Control Manager with all remote changes (if any) selected, ready to pull using Get Latest. When Source Control Manager is already open, this option refreshes it and selects all remote database changes. |
| Export Data | Opens the Data Export wizard to export data to a file with the supported file extension. |
| Duplicate Object | Opens the Duplicate Object dialog to copy object structure and/or data. |
| Generate Script As | Generates a script of the selected view using the CREATE, CREATE OR ALTER, DROP, DROP and CREATE, ALTER, SELECT, INSERT, UPDATE, DELETE, INSERT/UPDATE STORED PROCEDURE, or EXEC sp_refreshview statements. The view can be saved to a new SQL document or a file, or copied to the clipboard. |
| Send to > Query Builder | Adds the selected view to the Query Builder diagram. |
| Send to > Master Detail Browser | Adds the selected view to the Master Detail Browser document. |
| Send to > Database Diagram | Adds the selected view to a database diagram. |
| Send to > Data Report | Adds the selected view to a simple data report. |
| Send to > Chart Designer | Opens Chart Designer to create a chart. |
| Send to > Pivot Table | Opens the query document to create a pivot table. |
| Show Details | Opens Object Viewer to view object details. |
| Rename | Lets you enter a new name for the selected view. Shortcut: F2 |
| Delete | Drops the selected view from the database. Shortcut: Delete |
| Refresh | Updates the object to reflect the latest changes. Shortcut: F5 |
| Properties | Opens the Properties pane to view the object information. Shortcut: F4 |
The following table describes the shortcut menu options, which appear when you right-click the Views node in Database Explorer.
| Name | Description |
|---|---|
| New View | Opens View Editor to create and manage a view. |
| Source Control > Source Control Manager | Opens Source Control Manager, where you can track and manage changes to database schema and static data. When Source Control Manager is already open, this option refreshes it. |
| Source Control > Commit | Opens Source Control Manager with all local changes (if any) selected and ready to commit. When Source Control Manager is already open, this option refreshes it and selects all local database changes. |
| Source Control > Get Latest | Opens Source Control Manager with all remote changes (if any) selected, ready to pull using Get Latest. When Source Control Manager is already open, this option refreshes it and selects all remote database changes. |
| Tasks > Export Data | Opens the Data Export wizard to export data to a file with the supported file extension. |
| Filter | Opens the Filter Settings dialog to control which views should appear in Database Explorer. |
| Show Details | Opens Object Viewer to view object details. |
| Refresh | Updates the object to reflect the latest changes. Shortcut: F5 |
Note
After opening the Views node, the number of objects it contains appears in parentheses next to the node name. This number changes based on your filter settings.
The Source Control shortcut menu is available only if you linked the corresponding database to a source-control system.
In Database Explorer, hold down Ctrl and select multiple views. Then right-click the selection and select the required option.
The following table describes the shortcut menu options available for multiple views.
| Name | Description |
|---|---|
| Open Editor | Opens View Editors for each selected view. |
| Open Data in Editor | Opens the Data tab of View Editors for each selected view. |
| Select All Rows | Retrieves data from the selected views. |
| Source Control > Source Control Manager | Opens Source Control Manager, where you can track and manage changes to database schema and static data. When Source Control Manager is already open, this option refreshes it. |
| Source Control > Commit | Opens Source Control Manager with all local changes (if any) selected and ready to commit. When Source Control Manager is already open, this option refreshes it and selects all local database changes. |
| Source Control > Get Latest | Opens Source Control Manager with all remote changes (if any) selected, ready to pull using Get Latest. When Source Control Manager is already open, this option refreshes it and selects all remote database changes. |
| Source Control > Link/Unlink Static Data | Opes the Source Control Link Static Data dialog that displays the tables whose data you want to link. |
| Export Data | Opens the Data Export wizard to export data from the selected views. This option is available only for the views located on the same server. |
| Generate Script As | Generates a script of the selected objects using the CREATE, CREATE OR ALTER, DROP, DROP and CREATE, ALTER, SELECT, INSERT, UPDATE, DELETE, INSERT/UPDATE STORED PROCEDURE, and EXEC sp_refreshview statements.The script can be generated to a new SQL document or a file, or copied to the clipboard. |
| Send to > Query Builder | Adds the selected views to the Query Builder diagram. |
| Send to > Master Detail Browser | Adds the selected views to the Master Detail Browser document. |
| Send to > Database Diagram | Adds the selected views to a database diagram. |
| Delete | Drops the selected views from the database. Shortcut: Delete |
