1

Just started using the H2 database. Have found the COMMENT command but as I have already set the comment through LibreOffice, is there any way to return it? This is a sense check as I can set and see column comments in H2 via Squirrel, but Squirrel does not show comments set via Libre.

thanks

paul

Paul Eden
  • 338
  • 1
  • 3
  • 10

1 Answers1

2

Comment are usually used as a remark on the source code. You will get them back when running the SCRIPT statement.

But you can also retrieve them from the database meta data, as follows:

CREATE TABLE TEST(ID INT PRIMARY KEY, 
  NAME VARCHAR(255) COMMENT 'Hello World');

(SELECT TABLE_NAME, COLUMN_NAME, REMARKS 
  FROM INFORMATION_SCHEMA.COLUMNS
  WHERE REMARKS <> '')
UNION ALL
(SELECT TABLE_NAME, '', REMARKS 
  FROM INFORMATION_SCHEMA.TABLES
  WHERE REMARKS <> '')
ORDER BY TABLE_NAME, COLUMN_NAME;
Lubo
  • 1,621
  • 14
  • 33
Thomas Mueller
  • 48,905
  • 14
  • 116
  • 132
  • The purpose of the post is to try to determine if I have found a bug in Squirrel - running the above returns ~no~ columns with comments, although I know there should be at least one created from Squirrel and several created from LibreOffice. Are the Libre comments just stored in the Base file as a metadata overlay, do you know?. – Paul Eden Jan 30 '14 at 21:08
  • I'm sorry, this I don't know. You could check using the `SCRIPT` command if there are comments on the column (this I would do first I guess). – Thomas Mueller Jan 31 '14 at 09:24