Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to see all tables in my h2 database at localhost:8082?

Tags:

java

h2

I use JDBC and created h2 database called usaDB from sql script. Then I filled all tables with jdbc.

The problem is that after I connect to usaDB at localhost:8082 I cannot see on the left tree my tables. There is only INFORMATION_SCHEMA database and rootUser which I specified creating usaDB.

How to view the content of tables in my h2 database?

I tried query SELECT * FROM INFORMATION_SCHEMA.TABLES.

But it returned many table names except those I created. My snapshot:

enter image description here

like image 637
Volodymyr Levytskyi Avatar asked May 01 '14 07:05

Volodymyr Levytskyi


People also ask

How can I see table in H2 database?

Accessing H2 Console. Start the spring boot application and access the console in the browser with this URL : http://localhost:8080/h2 . We can see the console like this. Now enter the configured username and password.

How do I access my localhost H2 database?

If you started the server on the same computer as the browser, open the URL http://localhost:8082 . If you want to connect to the application from another computer, you need to provide the IP address of the server, for example: http://192.168.0.2:8082 .

How do I list all tables in DB?

All Database Tables If you want to list all tables in the Oracle database, you can query the dba_tables view. SELECT table_name FROM dba_tables ORDER BY table_name ASC; This view (and all others starting with dba_) are meant for database administrators.


2 Answers

I had the same issue and the answer seems to be really stupid: when you type your database name you shouldn't add ".h2.db" suffix, for example, if you have db file "D:\somebase.h2.db" your connection string should be like "jdbc:h2:file:/D:/somebase". In other way jdbc creates new empty database file named "somebase.h2.db.h2.db" and you see what you see: only system tables.

like image 117
Le_Enot Avatar answered Sep 19 '22 23:09

Le_Enot


You can use the SHOW command:

grammar

Using this command, you can lists the schemas, tables, or the columns of a table. e.g.:

SHOW TABLES 
like image 32
Paul Vargas Avatar answered Sep 20 '22 23:09

Paul Vargas