`
nicegege
  • 浏览: 580114 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

oracle序列使用

 
阅读更多

1.oracle的序列为我们提供每一条记录的唯一编号,最适合给主键赋值。

(1).创建序列:

create sequence student_sequ increment by 1 start with 23050601 maxvalue 23050632
nocycle nocache;

重命名序列:rename  student_sequ  to worker_sequ;

(2).创建表

create table worker (id integer,name varchar2(10),age integer , primary key (id));

(3).插入两条数据

insert into worker values(worker_sequ.nextval,'wangqiang',34);

insert into worker values(worker_sequ.nextval,'武松',25);

(4).查询数据

SQL> select * from worker for update;

        ID NAME              AGE
---------- ---------- ----------
  23050601 wangqiang          34
  23050602 武松               25

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics