一、创建表

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 

-- 如果有数据就对了!!!!!!!!

相关文章:

  • 2021-12-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-27
  • 2022-12-23
  • 2021-12-07
  • 2022-02-16
猜你喜欢
  • 2022-01-20
  • 2022-12-23
  • 2022-02-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案