序列和自增列
适用于 ✅ 开源版 ✅ 专业版 ✅ 企业版
序列实现了 org.jooq.Sequence
接口,本质上提供了以下功能
// Get a field for the CURRVAL sequence property Field<T> currval(); // Get a field for the NEXTVAL sequence property Field<T> nextval();
因此,如果您在 Oracle 中有这样的序列
CREATE SEQUENCE s_author_id
那么您可以在 SQL 语句中直接使用您的 生成的序列 对象,如下所示
// Reference the sequence in a SELECT statement: Field<BigInteger> s = S_AUTHOR_ID.nextval(); BigInteger nextID = create.select(s).fetchOne(s); // Reference the sequence in an INSERT statement: create.insertInto(AUTHOR, AUTHOR.ID, AUTHOR.FIRST_NAME, AUTHOR.LAST_NAME) .values(S_AUTHOR_ID.nextval(), val("William"), val("Shakespeare")) .execute();
反馈
您对此页面有任何反馈吗? 我们很乐意听取您的意见!