sql> create table sms_activity(
2id number,
3student_name varchar2(50),51); font-family:Arial; font-size:14px; line-height:26px"> 4 begin_time varchar2(30),51); font-family:Arial; font-size:14px; line-height:26px"> 5 end_time varchar2(30),51); font-family:Arial; font-size:14px; line-height:26px"> 6 content varchar2(600)
7 );
表已创建。
sql> commit;
提交完成。
sql> alter table sms_activity addprimary key (id);
表已更改。
sql>create sequence sms_activity_seq
2 minvalue 1
3 maxvalue 9999999999
4 increment by 1
5 cache 20
6 ;
序列已创建。
sql>create or replace triggerbi_activity
2 before insert on sms_activity
3 for each row
4 begin
5 select sms_activity_seq.nextval into :NEW.ID from dual;
6 end;
7 /
触发器已创建
sql>desc sms_activity
名称 是否为空? 类型
------------------------------------------------- ----------------------------
ID NOTNULL NUMBER
ACTIVITY_NAMEVARCHAR2(50)
BEGIN_TIMEVARCHAR2(30)
END_TIMEVARCHAR2(30)
CONTENTVARCHAR2(600)
sql> alter table sms_activity add(create_time varchar2(30),createby varchar2(20),modify_timevarchar2(30),modifyby varchar2(20));
sql> commit; 创建序列 create sequence seq_createid minvalue 1 maxvalue 999999 increment by 1 start with 1 cache 20 noorder cycle; 创建触发器 create or replace trigger tr_createid before insert on tb_user for each row when(new.id is null) begin select seq_createid.nextval into :new.idfrom dual; end;
原文链接:https://www.f2er.com/oracle/210977.html