oracle 创建触发器 设置主键id为uuid,crate_date为当前时间 建表语句

--create trigger
create or replace trigger tri_configurate_person --triggername
before insert on configurate_person --table name
for each row--循环添加
declare
begin
  if :new.configurate_id is null then --判断主键id是否为空
    :new.configurate_id:=sys_guid();--设置uuid
  end if;
  if :new.create_time is null then--判断创建时间是否为空
    :new.create_time:=SYSDATE();--创建当前系统时间
  end if;
end tri_configurate_person;

注意:new 后面是自己的字段名

建表语句

-- Create table
create table test1111 
(
id				  VARCHAR2(64) not null,
test1111                   VARCHAR2(64),
test1111                    VARCHAR2(64),
test1111                     VARCHAR2(64),
test1111                    VARCHAR2(5),
test1111                      VARCHAR2(5),
create_time                   DATE


)                                

tablespace USERS
  pctfree 10
  initrans 1
  maxtrans 255
  storage
  (
    initial 64K
    minextents 1
    maxextents unlimited
  );
  
-- Add comments to the columns 
comment on column ivr_login.id			  is '主键id';
comment on column ivr_login.test1111               is '姓名';
comment on column ivr_login.test1111                is '密码';
comment on column ivr_login.test1111                 is '工号';
comment on column ivr_login.test1111                is '角色等级,1:管理员 2:一级客户经理 3:';
comment on column ivr_login.is_login                  is '是否退出';
comment on column ivr_login.create_time               is '创建时间';

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值