INSERT, and get the auto-incremented value

后端 未结 3 1557
梦毁少年i
梦毁少年i 2021-01-20 15:22

Consider the following table:

create table language (
    id integer generated always as identity (START WITH 1, INCREMENT BY 1),
    name long varchar,
             


        
3条回答
  •  我在风中等你
    2021-01-20 16:09

    You use the JDBC method

    st.execute(sql, Statement.RETURN_GENERATED_KEYS);
    ResultSet keys = st.getGeneratedKeys();
    

    as documented in the Derby manual.

    See also Javadocs: DatabaseMetaData#supportsGetGeneratedKeys() and Statement#getGeneratedKeys()

提交回复
热议问题