Hi,

auto_increment is saved as sequences.

If you are like me, who create tables with auto_increment,
H2 will change it with
int not null default (next value for <schema.sequence_name>) not null
null_to_default sequence <sequence name>

you can confirm it using
select "SQL" from information_schema.tables where table_schema =
'YOUR_SCHEMA_NAME_IN_ALL_CAPS' and table_name =
'YOUR_TABLE_NAME_IN_ALL_CAPS'

now that you know the <schema.sequence_name> ,next run
select * from information_schema.sequences where sequence_schema =
'<schema>' and sequence_name = '<sequence_name>'

i think current_value is what you are looking for.

Hope that helps.
evan

On Jun 15, 2:29 pm, korwru <[email protected]> wrote:
> How can I get the current number of ID (auto_increment) for a specific
> table in the database?
>
> I'm looking for a query identical IDENT_CURRENT in database MS SQL.
>
> In JDBC a method getGeneratedKeys () returns the ID value, but only
> after INSERT-query.

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en.

Reply via email to