Working with Views
Some of the features on this page are only in DbVisualizer Pro.
A view is a stored SELECT statement that you can query like a table. In DbVisualizer, you work with views mostly as with tables. This page describes what is different, and links to the table pages for the rest.
Creating a view
For most databases, there is no dialog for creating a view. Instead, you execute a CREATE VIEW statement in SQL Commander:
- Write the
SELECTstatement of the view, or create it in the Query Builder and copy it to the SQL editor. - Add
CREATE VIEW name ASbefore theSELECTstatement. - Execute the statement.
For Oracle, BigQuery and NuoDB, you can also right-click the Views node in the Databases tab and select Create View. Enter the name and the SELECT statement, and click Execute. For Oracle, the dialog uses CREATE OR REPLACE VIEW, so you can also use it to change a view.
Changing a view
There is no dialog for altering a view. To change it, you create it again with a new SELECT statement:
- Double-click the view in the Databases tab, and select the DDL tab in its Object View tab. The DDL tab is only in DbVisualizer Pro.
- Right-click the DDL and select Copy to New Editor. The
CREATE VIEWstatement opens in a new SQL Commander tab. - Change the
SELECTstatement. To change it in the Query Builder, copy only theSELECTstatement to an empty SQL Commander tab, and click Load SQL into the Query Builder. The Query Builder loads all text in the editor. - Drop the view: right-click it in the Databases tab and select Drop View.
- Execute the changed
CREATE VIEWstatement.
If the database supports CREATE OR REPLACE VIEW, you can use that instead, and skip dropping the view.
For some databases, the right-click menu of a view has more actions, such as Rename View, or Refresh Materialized View for a materialized view.
What works as for tables
- Viewing and editing data: the Data tab of a view works like the one of a table. See Viewing Table Data and Editing Table Data. Editing is only in DbVisualizer Pro, and whether you can change the data through a view depends on the database and the view.
- Exporting: for most databases, right-click the view and select Export View. Exporting is only in DbVisualizer Pro. See Exporting a Table.
- Viewing the DDL: select the DDL tab in the Object View tab of the view. The DDL tab is only in DbVisualizer Pro. See Viewing the Table DDL.
- Generating SQL: for most databases, right-click one or more views and select Script View. Scripting several views at once is only in DbVisualizer Pro. See Generating SQL for a Table.
- Filtering the tree: to show only some views in the Databases tab, which is only in DbVisualizer Pro, see Filtering Database Objects.