建表:
用户必须被显示的赋予创建触发器的权限才可以创建trigger
1、用sys/1234登陆sqlplus
2、在command窗口输入:grant create any trigger to sprita1;
3、提示Grant succeeded表明赋予成功
创建自增长主键的表:
create table student
(
id number not null primary key,
name varchar2(20) not null,
gender varchar2(20) not null,
startDate Date not null
);
// 注释
comment on table student is '学生信息表';
Comment on column student.id is 'id';
Comment on column student.name is '姓名';
Comment on column student.gender is '性别';
Comment on column student.startDate is '入学日期';
//序列
create sequence st_sqc increment by 1;
// 触发器
create or replace trigger std_tg_insert before insert on student for each row
begin
select st_sqc.nextval into :new.id from sys.dual;
end;
用户必须被显示的赋予创建触发器的权限才可以创建trigger
1、用sys/1234登陆sqlplus
2、在command窗口输入:grant create any trigger to sprita1;
3、提示Grant succeeded表明赋予成功
创建自增长主键的表:
create table student
(
id number not null primary key,
name varchar2(20) not null,
gender varchar2(20) not null,
startDate Date not null
);
// 注释
comment on table student is '学生信息表';
Comment on column student.id is 'id';
Comment on column student.name is '姓名';
Comment on column student.gender is '性别';
Comment on column student.startDate is '入学日期';
//序列
create sequence st_sqc increment by 1;
// 触发器
create or replace trigger std_tg_insert before insert on student for each row
begin
select st_sqc.nextval into :new.id from sys.dual;
end;