您的位置:首页 > 其它

创建表的id默认值为自动增长

2012-08-29 10:38 148 查看
1、创建表

create table DEVICE_TURN_ON

(

id NUMBER not null,

time TIMESTAMP(6) default sysdate not null,

tc_device_id VARCHAR2(32),

operation VARCHAR2(10) default 'ON'

);

2、创建sequence

create sequence white_list_device_SEQ

INCREMENT BY 1

START WITH 1

NOMAXVALUE

3、创建表的触发器

create or replace trigger tr_device_turn_on

before insert on device_turn_on

for each row

begin

select white_list_device_SEQ.nextval into :new.id from dual;

end;

4、插入数据测试



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