32. Working with the Database Object tree
Prev |  | Next

## 32. Working with the Database Object tree

The Database Object Tree offers a similar functionality as the Database Object Explorer but can be displayed alongside the SQL editor tabs. The DB Object tree offers a subset of the features the DbExplorer offers. The Database Object Tree can be displayed using Tools → Show DbTree.

The DB Object tree always uses a separate connection regardless of the configuration of the current connection profile.

The elements of each part of the tree are only loaded when the node is expanded for the first time.

### 32.1. Filtering the elements in the tree

The quick filter above the object tree can be used to quickly search for objects with a specific name. The filtering will only be done on already loaded elements of the tree.

The behavior of the quick filter is the same as the filter in the DbExplorer

### 32.2. Drag and drop support

#### 32.2.1. Dropping elements into the SQL editor

In general, dropping an element into the editor, will insert the element's name into the editor. There are however two exceptions to this rule:

- dropping the "Columns" node of the tree will insert a comma separated list of all columns
- dropping a table into a position where no current SQL statement is located, a `SELECT` statement for the table will be inserted
- in all other cases, the name of the dropped element will be inserted (e.g. the name of the table, column or index)

#### 32.2.2. Displaying a table's data

To display the data of a table, drag the table node from the Database Object Tree to the result panel of the current SQL editor. SQL Workbench/J will then generate an appropriate `SELECT` statement for the table and execute it immediately.

### 32.3. Finding elements in the tree

When the object tree is displayed, the context menu of the editor contains a new item Find in object tree. This will try to find and select the identifier at the cursor location in the Object Tree.

If the schema (or catalog) that contains the object has not yet been loaded, it will be loaded in order to be able to display the current identifier.

### 32.4. Features available through the context menu

The Database Object Tree offers some of the features that are available in the DbExplorer

#### Export data

> This exports the data from the selected table(s). This is identical to the function in the DbExplorer.

#### Find in object tree

> This menu choice is only available when right clicking on a table in the "References" or "Referenced by" nodes. It will then find and select the referenced (or referencing) table in the DbTree.

#### Count rows

> This will count the rows for each selected table object. The row counts will be shown in parentheses next to the table name. This is the same functionality as the `WbRowCount` command.

#### Put SELECT into

> This will put a SELECT statement into the SQL editor to display all data for the selected table. You can choose into which editor tab the statement will be written. The currently selected editor tab is displayed in bold

> The generated SELECT statement is always inserted into the editor's text at the current cursor position.

#### Create empty INSERT

> This creates an empty `INSERT` statement for the currently selected table(s). This is intended for programmers that want to use the statement inside their code.

> The generated SELECT statement is always inserted into the editor's text at the current cursor position.

#### Create empty UPDATE

> This creates an empty `UPDATE` statement for the currently selected table(s). This is intended for programmers that want to use the statement inside their code.

> The generated SELECT statement is always inserted into the editor's text at the current cursor position.

#### Create default SELECT

> This creates a `SELECT` for the selected table(s) that includes all columns for the table. This feature is intended for programmers who want to put a SELECT statement into their code.

> The generated SELECT statement is always inserted into the editor's text at the current cursor position.

#### Create DDL Script

> This shows the SQL source for the selected object(s). This is identical to the function in the DbExplorer.

#### Drop

> Drops the selected objects. This is identical to the function in the DbExplorer.

#### Generate DROP script

> This creates a script to DROP the selected object(s) including dependent objects. This is identical to the function in the DbExplorer.

#### Delete data

> Deletes all rows from the selected table(s) by executing a `DELETE FROM table_name;` to the server for each selected table. This is identical to the function in the DbExplorer.

Prev |  | Next
31. Database Object Explorer | Home | 33. Common problems