Introduction
When you work with a database, there are often some set of SQL
statements that you use over and over to perform frequent tasks. You
probably have them saved in script files that you can load into an SQL
Editor, but DbVisualizer Bookmarks make it even easier to work with
them. A Bookmark is a script visible in the Scripts tab in the tree
area of the GUI.
Other times you type SQL statements directly in an SQL Editor and
execute them. Later you may realize that you need to execute a
statement again. You can then use the History window to locate the
statement and reuse it.
In this chapter, you will learn all about how to use Bookmarks and the
History.
Bookmarks
You find your Bookmarks under the
Scripts
tab in the tree area to the left in the main DbVisualizer window. The
content of a Bookmark is one or more SQL statements. It may also be
associated with a Connection, a Catalog and a Schema, to be used when
executing the statements. This information is displayed, and can be
edited, in the lower part of the Scripts tab, along with information
about the file that holds the Bookmark. If you don't want to see these
details, you can disable it with the
Show
Details toggle control in the right-click menu for a node.
Figure: The Scripts tab with Bookmarks
Creating, Editing and
Organizing Bookmarks
You can create a new Bookmark by selecting the
Bookmarks node in the tree and
clicking the
Create File
toolbar button. This adds a new node in the tree, with the default name
selected so that you can replace it with the name you want to use. You
can also rename the Bookmark later using the
Rename toolbar button with the node
selected.
A Bookmark can also be created from the current content in an SQL
Editor. Click the
Save File As
toolbar button to open a file chooser dialog, and click the Bookmarks
button in the file chooser dialog to go to the Bookmarks root
directory. Enter a filename for the Bookmark and click
Save.
Figure: The File Chooser dialog
To put some SQL statements in a new empty Bookmark or to edit the
contents of an existing Bookmark, you need to open the Bookmark in an
SQL Editor. If you want to use the SQL Editor you currently have open,
you can double-click the Bookmark node in the tree or click the
corresponding toolbar button. If you want to edit the Bookmark in a new
editor, use the right-click
Open File
-> Open in New Editor operation or press Alt and then
double-click. When you are done with your
edits, use the
Save toolbar
button in the SQL Editor to save them.
The default open behaviour when double-click a script
file can be
configured in Tool
Properties->Script category.
You can also add the content of a Bookmark to the current content of an
SQL Editor. Select the Bookmark node, drag it with the mouse key
depressed to the position in the editor where you want to add it, and
drop it there by releasing the mouse button.
Folders can be used to organize your Bookmarks. Click the
Create Folder toolbar button to
create a new folder and give it the name you want. You can then drag an
existing Bookmark node to the folder, and create new Bookmarks and
subfolders in the folder by selecting it and clicking the
Create File and
Create Folder buttons.
The order of the folders and the Bookmarks within a
folder is determined by the filesystem and cannot be changed manually.
Executing Bookmarks
With a Bookmark opened in the SQL Editor, you can of course execute its
statements by clicking the
Execute
toolbar buttons as usual, but you can also open and execute a Bookmark
directly by selecting it in the tree and using the
Execute File operations in the
right-click menu.
Figure: The Execute File operations
in the right-click menu for a Bookmark
Adding a Bookmark as
a Favorite
If you are using a Bookmark very often, you may find it more convenient
to add it to the
Favorites area.
You
can
drag and drop a Bookmark from the Scripts tab to the Favorites
area, or launch the Favorites editor via the
Add to Favorites right-click menu
operation.
Sharing Bookmarks
It's easy to share your Bookmarks with someone else because they are
stored as regular files. The files are located in a subfolder of the
DbVisualizer user preferences folder named
Bookmarks. The user preferences
folder is typically a subfolder named
.dbvis
in your home folder.
The main Bookmark content is stored in a file with exactly the same
name as the node in the Scripts tab. The additional data associated
with the Bookmark is stored in a file with the same name plus the
.met extension.
To share some of your Bookmarks with someone, we recommend that you use
DbVisualizer to create a separate Bookmarks subfolder for the shared
Bookmarks. You can then use any external tool to create a file archive
(e.g. a ZIP file) of that subfolder and send it to your friend or
colleague. He or she can then extract the files into the local
DbVisualizer user preferences
Bookmarks
folder.
History
As you execute SQL statements in the SQL Commander, DbVisualizer saves
them as History entries, along with information about the Connection,
Catalog, Schema and the execution result. This makes it easy to locate
statements and scripts you have executed in the past.
If you just want to go back and forth between statements you have
executed recently, you can use the
Get
Previous
from
History and
Get
Next from History toolbar buttons in the SQL Editor.
To look through all saved statements, you can display the History
entries by clicking the
Display SQL
History toolbar button in the main window or select the
corresponding operation from the
Tools
menu.
Figure: The SQL History window
The entries are ordered with the most recently executed entries at the
top by default, but you can reorder them by clicking on the column
headers. The complete content of the selected entry is shown below the
list, unless you disable it by clicking the
Show Details toolbar button or
select the corresponding operation from the right-click menu.
Reusing a History
Entry
When you have found the entry you're looking for, you can open it in
the current SQL Editor by double-clicking it or clicking the
corresponding toolbar button. If you want to open the entry in a new
editor, use the right-click
Open File
-> Open in New Editor operation.
You can also add the content of an entry to the current content of an
SQL Editor. Select the entry in the list, drag it with the mouse key
depressed to the position in the editor where you want to add it, and
drop it there by releasing the mouse button.
Saving a History
Entry as a Bookmark
If you realize that you need easy access to a History entry in the
future, you can save it is as a Bookmark. Just select the entry and use
the
Save as Bookmark
operation, or just drag it to the Bookmarks tree and drop it.
Quick Load
An alternative to locating Bookmarks in the Scripts tab and History
entries in the History window is to use the Quick Load feature, by
default bound to the
Ctrl+Alt+O
key combination. It is also available via a toolbar button in the SQL
Editor as well as in the main
File->Quick
File Open
menu.
Figure: Quick Load window
The Quick Load feature locates
files with partly matching names from the categories you have selected,
as you type. You can use an asterisk ("*") as a wildcard in the search
string.
When you see the file you're looking for, just select it and click
Enter to load it into an SQL Editor. Use the New Editor checkbox to
decide whether you want to open it in a new editor or in the current
editor, and use the Max field to limit the number of matching files to
display in the list.
Copyright © 2010 DbVis Software AB. All rights reserved.