oracle创建触发器

淩亂°似流年 2022-01-29 10:11 447阅读 0赞

原因是:序列是在系统管理员权限下建的,而触发器又是在普通用户下建的,所以,在触发器中使用系统管理员权限下建的序列就无效了。

解决方法:同一个用户下建序列和触发器,即可。

1。先sqlplus登录了:

SQL> conn gch/gch;

2。建表:

create table position
(
id number(10) not null,
deviceName varchar2(30) not null primary key,
imageName varchar2(30) not null,
effectName varchar2(30) not null,
xPos number(6) not null,
yPos number(6) not null,
data number(10,4)
)
tablespace users
/

3。建序列:

create sequence position_seq

start with 1

increment by 1

minvalue 1

maxvalue 9999999

nocycle

nocache

noorder;

/

4。建触发器:

create or replace trigger position_trigger
before insert on position
for each row
begin
select position_seq.nextval into:new.id from sys.dual;
end;
/

5。好了,insert一条记录测试一下喽。。。。

发表评论

表情:
评论列表 (有 0 条评论,447人围观)

还没有评论,来说两句吧...

相关阅读

    相关 mysql创建触发器

    很多时候为了提高查询效率,我们会在一些表当中增加冗余字段,例如在客户表里面保存用油卡号,但是如果客户挂失原卡,申请了新的油卡,冗余字段就不正确了, 这时候应该怎么办呢?我们可

    相关 oracle创建触发器

    原因是:序列是在系统管理员权限下建的,而触发器又是在普通用户下建的,所以,在触发器中使用系统管理员权限下建的序列就无效了。 解决方法:同一个用户下建序列和触发器,即可。  

    相关 zabbix--创建触发器

    触发器  概述 触发器是“评估”由监控项采集的数据并表示当前系统状况的逻辑表达式。 当监控项用于采集系统的数据时,始终遵循这些数据是非常不切合实际的,因为这些数据始终