Ralph
Ralph

Reputation: 120771

Does H2 support a collation defintion for one single column?

I want to make a single H2 column in a H2 database to have a other collation (case insensitive) then the other columns (that are case sensitive).

In MySQL I would do this:

ALTER TABLE users MODIFY login VARCHAR(255) COLLATE utf8_general_ci

Is there a similar feature in H2?

Upvotes: 3

Views: 5386

Answers (2)

O.Badr
O.Badr

Reputation: 3121

From H2 reference guide:

ALTER TABLE users ALTER COLUMN login VARCHAR_IGNORECASE(255)

Upvotes: 1

Thomas Mueller
Thomas Mueller

Reputation: 50087

H2 only supports one collation per database (via SET COLLATION statement).

What it does support is a case-insensitive data type, VARCHAR_IGNORECASE. Internally, this data type is using String.compareToIgnoreCase. This may or may not work for your use case.

Upvotes: 6

Related Questions