復(fù)制代碼 代碼如下:
--創(chuàng)建sequence
create sequence seq_on_test
increment by 1
start with 1
nomaxvalue
nocycle
nocache;
--建表
drop table test;
create table test(
ID integer
,stu_name nvarchar2(4)
,stu_age number
);
--插入數(shù)據(jù)
insert into test values(seq_on_test.nextval,'Mary',15);
insert into test values(seq_on_test.nextval,'Tom',16);
select * from test;
--結(jié)果
/*
1 Mary 15
2 Tom 16
*/
--seq的兩個(gè)方法
select seq_on_test.currval from dual;
select seq_on_test.nextval from dual;
--結(jié)果
/*
2
3
*/
新聞熱點(diǎn)
疑難解答
圖片精選