在H2数据库中自动增量ID [英] auto increment ID in H2 database
本文介绍了在H2数据库中自动增量ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有一个auto_incrementing BIGINT ID的表。
可以这样定义
id bigint auto_increment
pre>
但没有效果(它不会自动递增)。
我想插入所有字段,但ID字段 - ID字段应该由DBMS提供。
或者我需要调用一些东西来增加ID计数器吗?解决方案JDBC网址:
jdbc:h2:〜/ temp / test2
表测试;
create table test(id bigint auto_increment,name varchar(255));
insert into test(name)values('hello');
insert into test(name)values('world');
select * from test;
结果:
code> ID NAME
1 hello
2 world
Is there a was to have an auto_incrementing BIGINT ID for a table. It can be defined like so
id bigint auto_increment
but that has no effect (it does not increment automatically). I would like to insert all fields but the ID field - the ID field should be provided by the DBMS. Or do I need to call something to increment the ID counter?
解决方案It works for me. JDBC URL:
jdbc:h2:~/temp/test2
drop table test; create table test(id bigint auto_increment, name varchar(255)); insert into test(name) values('hello'); insert into test(name) values('world'); select * from test;
result:
ID NAME 1 hello 2 world
这篇关于在H2数据库中自动增量ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文