oracle 自增字段 以及插入包含自增字段的过程

来源:互联网 发布:剑网三脸型数据成男 编辑:程序博客网 时间:2024/05/22 01:59
在oracle数据库中,没有ORACLE自增字段这样的功能,但是通过触发器(trigger)和序列(sequence)可以实现。
假设[表cwhmi_heritage]关键字段为id,建一个序列,代码为:
[html] view plaincopy
create sequence seq_cwhmi_heritage 
minvalue 1     --最小值  
maxvalue 99999999999  --最大值  
start with 1   -- 从1开始计数   
increment by 1  -- 每次加几个  
nocache    --没缓存  
order;  

insert into cwhmi_heritage 
(id,hrt_name,hrt_type,HRT_LOCATION_STR)
values
(seq_cwhmi_heritage.nextval,'故宫','世界文化遗产','116.3904444653639.917065662948');
0 0
原创粉丝点击