這是創(chuàng)建了一個sequence
create sequence S_S_DEPART
minvalue 1
maxvalue 999999999999999999999999999
start with 1
increment by 1
nocache;
SQL> create sequence S_S_DEPART
2 minvalue 1
3 maxvalue 999999999999999999999999999
4 start with 1
5 increment by 1
6 nocache;
Sequence created
SQL> select S_S_DEPART.nextval from dual;
NEXTVAL
----------
1
SQL>
SQL> select S_S_DEPART.nextval from dual;
NEXTVAL
----------
2
以上是測試代碼:
在java中的應(yīng)用如下:
/**
* 獲取項(xiàng)目的序列號
* @author 劉威
* @return 項(xiàng)目序列號str
*/
public String getProjectSn(){
String snNum = "P20";
Session session = this.getSession();
String sql="select PROJECT_SEQ.nextval from dual";
Query query = session.createSQLQuery(sql);
snNum = snNum + query.uniqueResult().toString();
return snNum;
}
本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請
點(diǎn)擊舉報。