Search code examples
sqlinserth2h2db

why H2 database append prefix before my value


I have a table in H2 database.
In this table there are 2 columns like below:

CREATE TABLE mytable (id bigserial NOT NULL,lffo_file text);

id | value --------------

I execute this query :

 INSERT INTO mytable (value , id) VALUES ( '/resource/public/1555687199892.js','1555684557909')

After that when I execute this query:

select * from my table

It shows me :

id              |      value
-----------------------------------------
1555684557909   |  clob4: '/resource/public/1555687199892.js'

Why does H2 append this prefix << clob4: >> ?

(I just know ,clob is data type for huge varchar)


Solution

  • after a while

    H2 database automaticly consider Text as clob datatype
    and when you create a table with Text column it was changed to clob

    and then:
    when you insert a text value it persist a text like KVP format :
    suppose you inserted 'Alex' and then 'Beti' in the value column

    so it persist like below:

    value clob0 : 'Alex' clob1 : 'Beti'

    as you see in the kvp, key is 'clobe' + counter

    so i changed text type to varchar (without size) and depend on postgresql documentation there is no difference between varchar and text performance

    all of this is what i saw and if there is a better answer please share it, thanks