2013-09-30 46 views

回答

15

如果你想使用自己的序列:

create sequence group_seq; 
create table test3(id bigint default group_seq.nextval primary key); 

如果不是:

create table test1(id identity); 

create table test2(id bigint auto_increment primary key); 

所有這一切都在H2 SQL grammar railroad diagrams被記錄在案。

+0

我該如何指定id是主鍵? – user1154644

+0

我更新了我的答案。 –

+0

@ThomasMueller當我使用我的自定義序列時,它不會獲得Hibernate的auto_generated。當我使用auto_increment標誌時,它工作正常。我檢查Information_Schema.Sequences,發現IS_GENERATED列對於系統生成的序列設置爲true,對於自定義序列則設置爲false。有沒有辦法將自定義序列設置爲true? – Arham

相關問題