Wednesday, March 4, 2009

How to use H2 shell

H2 is one of the fastest database which comes under modified version of the MPL 1.1 ( Mozilla Public License ) or under the (unmodified) EPL 1.0 ( Eclipse Public License ).

H2 Shell is a command line database tool which can be used for any of the database sql operation. To run the H2 shell go to the bin directory of your H2 installation and run the following.

java -cp h2*.jar org.h2.tools.Shell

Once you run the tool it will ask some connection details.
URL       jdbc:h2:tcp://localhost/~/test1
Driver org.h2.Driver
User sa
Password sa
Connected
Commands are case insensitive; SQL statements end with ';'
help or ? Display this help
list Toggle result list mode
maxwidth Set maximum column width (default is 100)
show List all tables
describe Describe a table
quit or exit Close the connection and exit

sql>
Users can either use H2 shell or web console. H2 web console will allow you to access sql database using a browser. One of my colleague has written nice blog entry on getting started with H2 database and using the H2 web console.

1 comment:

Tomek said...

Thank you, that was exactly what I wanted to know!