一、创建表
create table testTable
(
Id numbere,
name varchar2(100),
age number,
createTime date,
primary key(Id)
)
二、创建序列
create sequence seq_test
三、创建触发器
create or replace trigger autoId
before insert on testTable for each Row when (NEW.ID is null)
begin
select seq_test.nextval into :new.ID from dual;
end;
/
四、添加一条信息
insert into testTable(name,age,createTime) values('testname',11,'2019-4-4')
五、查看表
select * from testTable
-- 如果有数据就对了!!!!!!!!