This topic describes how to quickly drop multiple database objects of a certain type with the example of views. The view is a pre-established SQL query command, which returns a result set and kept in the database dictionary. On SQL level, views can be accessed as regular tables.
Important Notes About Database Views
- Database Tour lists database views in the table list of the Object Browser, which occupies the left part of the main window. If the Object Browser is collapsed, click a vertical splitter at the left side of the window.
- The interface of views is continuously developing. Currently, it is finished for a certain list of database types (see the full list here). For other database types, Database Tour sees the views as regular tables. In this topic, let's assume we work with a database, for which the interface of views is ready, e.g. Oracle or PostgreSQL.
- Some views in some databases can be used in other database objects, so their dropping may affect those objects. Some databases do not allow to drop a view if other objects depend on it (such objects must be changed or deleted first).
Steps to Drop Multiple Views
- Open the needed database.
- Switch to the Tables tab of the Object Browser.
- Ensure the list of tables is sorted by type. You can do it by right-clicking the list and choosing Sort by menu. When the list is sorted by type, database views will be grouped at the end of it, where it would be easier to select them.
- Right-click the table list and choose Multiple Selection.
- Select the views to drop.
- Right-click selected items and choose Generate SQL | Drop... menu. A new SQL window will be created and filled with the script to drop all selected objects.
- Click Execute query button.
- If the Commit button is active, click it to commit changes.
See also