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

你可能感兴趣的:(oracle)