Creating
a Transactional Environment in Berkeley DB
Before You Begin
This is the first tutorial in the Getting Started with
the Graphical User Interface in Berkeley DB series.
Perform both these tutorials sequentially as there is a
dependency to complete one before starting the other.
Creating a Transactional Environment in Berkeley DB
In this first tutorial, you will create a transactional
environment, create a database, create and manipulate data, and
perform database transactions using the new Graphical User
Interface in Berkeley DB 18.1.
This tutorial takes approximately 10 minutes to complete.
Background
Berkeley DB is a family of embedded key-value database
libraries providing scalable high-performance data management
services to applications. It enables the development of custom
data management solutions, without any overhead. You can
configure Berkeley DB to address any application need from the
hand-held device to the data center, from a local storage
solution to a world-wide distributed one, and from kilobytes to
petabytes.
The Oracle Berkeley DB Graphical User Interface (BDB GUI) is
introduced in Berkeley DB 18.1 and provides a simple interface
for interacting with the Berkeley DB environment.
What Do You Need?
Install JDK 8 or higher version in your
machine. This is required to build and run Berkeley DB GUI.
A Berkeley DB environment is a container that holds and manages
databases.The Create Environment page is the first page that
appears when you start a Berkeley DB GUI and allows you perform
the operations on an environment such as create, open, backup,
recovery, remove old logs, upgrade, verify data, and verify
logs.
In this section, you create a transactional environment.
Select a environment home directory to store any future
databases, logs, and other files belonging to the environment.
Click the Browse button by Environment Home
and select a directory in which you want to store the
environment.
Description
of the illustration sect_2_01.jpg
Select a cache size of 25 megabytes. Enter 26214400
in the Cache Size box and click the Create
button.This will move the GUI to the Database Page.
Description
of the illustration sect_2_04.jpg
You see a message "Environment successfully created."
at the bottom of the screen. This confirms that the
environment is created successfully.
Description
of the illustration sect_2_05.jpg
The Database page allows you to perform operations on
databases, such as create, open, compact, remove, and rename. In
this section, you create a database by using the Berkeley DB
GUI.
Ensure that btree is the type of database
selected from the Database Type menu and select the page size
as 4096 from the Page Size menu.
Description
of the illustration sect_3_03.jpg
You see a message "Database successfully created."
at the bottom of the screen. This confirms that the database
is created successfully.
Description
of the illustration sect_3_05.jpg
To browse the data inserted into the database, click the Next
button in the Browse Data section.The words "foo"
and "bar" should appear in the Key and Data
text boxes.Description of
the illustration sect_4_03.jpg
Click Next again. The text boxes will be
empty, and the message "End of the database has been
reached, there is no next record." will appear at
the bottom of the page.
Description of
the illustration sect_4_05.jpg
Try to get the "hello" record again by
redoing step 6. The message "Database does not contain
that key." will appear at the bottom of the page.
Description
of the illustration sect_4_08.jpg
Begin,
Commit, and Abort a Transaction
A transaction is a logical unit of work that contains one or
more statements. The effects of all statements in a transaction
can be either all committed (applied to the database) or all
aborted (undone from the database). Perform the following steps
to begin, commit, and abort a transaction:
Note: This section appears in the Berkeley DB
GUI only if the environment is transactional.