创建表的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、插入数据测试
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、插入数据测试
相关文章推荐
- MySQL如何创建用户表并将其ID设置为自动增长列?
- 创建触发器在表中播入数据时ID自动增长
- Oracle 表创建序列-触发 实现表ID自动增长
- MySQL数据库--怎样创建一张用户表,ID设置为自动增长列(新手必会)
- MySQL数据库--怎样创建一张用户表,ID设置为自动增长列(新手必会)
- MySQL数据库--怎样创建一张用户表,ID设置为自动增长列(新手必会)
- hibernate映射oracle自动增长ID
- 在res文件夹下创建menu,但是R.java文件不能自动生成资源id
- 触发器修改后保存之前的数据 表中插入数据时ID自动增长
- 利用hibernate实现oracle(每张表的ID)自动增长
- Sql server 中关闭ID自增字段(SQL取消ID自动增长)
- powerdesigner 设置自动增长列(identity)和默认值
- oracle创建表,追加备注,添加主键,触发器,自动增长序列
- oracle创建自动增长列、触发器
- powerdesigner 设置自动增长列(identity),和默认值
- hibernate oracle ID 自动增长 1
- Oracle 触发器和序列的创建和使用 (自动增长列)
- .NET执行insert语句返回自动增长列ID的值
- 怎么在插入oracle记录的时候同时得到自动增长的ID值(未解决)
- Hibernate注解映射sequence时出现无序增长问题+hibernate 映射 oracle ID自动增长