Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use DESC command in H2 Database?

Tags:

h2

My friend showed me in ORACLE that using DESC Table NAme was showing information about columns of table. But running this command in H2 Database was giving error, Why? and please tell how to use this command in H2? Thanks.

like image 507
user1204320 Avatar asked Feb 14 '12 14:02

user1204320


People also ask

How do I view the contents of my H2 database?

Accessing the H2 Console H2 database has an embedded GUI console for browsing the contents of a database and running SQL queries. By default, the H2 console is not enabled in Spring. Then, after starting the application, we can navigate to http://localhost:8080/h2-console, which will present us with a login page.

How do I view H2 DB console?

Access the H2 Console You can access the console at the following URL: http://localhost:8080/h2-console/. You need to enter the JDBC URL, and credentials. To access the test database that the greeter quickstart uses, enter these details: JDBC URL: jdbc:h2:mem:greeter-quickstart;DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=-1.


2 Answers

you can use the show command just like:

sql> show columns from users; 

"users" is the table name, the output would be something like:

FIELD      | TYPE          | NULL | KEY | DEFAULT ID         | INTEGER(10)   | NO   | PRI | (NEXT VALUE FOR PUBLIC.SYSTEM_SEQUENCE_B66F0B87_5AAA_4421_88AC_1E8CAC372596) USERNAME   | VARCHAR(45)   | NO   |     | NULL PASSWORD   | VARCHAR(100)  | YES  |     | NULL FULL_NAME  | VARCHAR(100)  | YES  |     | NULL LAST_LOGIN | TIMESTAMP(23) | YES  |     | NULL (5 rows, 1 ms) 
like image 159
Roberto Avatar answered Sep 30 '22 06:09

Roberto


The H2 database does not support the SQL statement DESC.

It does support SHOW however, as documented. Example:

SHOW TABLES 
like image 44
Thomas Mueller Avatar answered Sep 30 '22 04:09

Thomas Mueller