您的位置:首页 > 数据库 > Oracle

oracle序列 自动增加

2011-08-29 15:43 211 查看
普通用户普通身份

create user yao identified by "654321"

grant connect,resource to yao

conn yao/654321

create table TP

(

ProID NUMBER primary key,

ProName VARCHAR2(20)

);

创建序列

create sequence SE

minvalue 1

maxvalue 9999999

start with 1

increment by 1

NOCYCLE

NOCACHE;

创建触发器

create or replace trigger tp_se

before insert on TP

for each row

begin

select se.nextval into:new.ProID from dual;

end;

插入数据

insert into TP values (1,'aa')

insert into TP (ProName) values ('bb')
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: