I have an application that has to load various H2 database files for different tasks at runtime and must be able to verify that the loaded DB conforms to a predefined schema. By this I mean that I query the information schema to check whether specific tables are present and whether these tables contain properly defined columns (eg data type, length, indexes etc).
My question is concerning H2's internal data types and how they map to values listed in INFORMATION_SCHEMA.COLUMNS
. For example am I correct that the data_type column in this table properly reflects a columns data type as given during table creation eg
CREATE TABLE test (id int primary key, some_string varchar(32) ... )
the int is mapped to a data type of 4? Is there a listing of the mappings of the data types to internal codes and do these ever change?
The column
DATA_TYPE
in the table tableINFORMATION_SCHEMA.COLUMNS
is mapped to column 5 (DATA_TYPE
) of the methodDatabaseMetaData.getColumns
. Per specification this is required to be an integer, as defined injava.sql.Types
. The constant4
meansINTEGER
.This is part of the JDBC standard and is not going to change.