ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 為創建的表建立序列和觸發器(5.5)

為創建的表建立序列和觸發器(5.5)

原创 Linux操作系统 作者:huangbin7097 时间:2013-01-22 17:18:38 0 删除 编辑

----
----grant create sequence,select any sequence to AutoMonitor;
----GRANT CREATE TRIGGER TO AutoMonitor;
--
/*Create sequence and trigger for ProduceLine id to increased in automatic*/

CREATE  SEQUENCE  AlexMonitor.PL_ID_Seq Minvalue 1 Maxvalue 10000000000
INCREMENT BY 1
START WITH 1;


CREATE OR REPLACE TRIGGER AlexMonitor.PL_ID_Trigger
BEFORE  INSERT ON AlexMonitor.ProduceLine
For each row
BEGIN
    SELECT PL_ID_Seq .NEXTVAL INTO:NEW.PL_ID from dual;
END;
--
----
--/*Create sequence and trigger for Server id to increased in automatic*/
--CREATE  SEQUENCE  AlexMonitor.Server_ID_Seq Minvalue 1 Maxvalue 10000000000
--INCREMENT BY 1
--START WITH 1;
--
--CREATE OR REPLACE TRIGGER AlexMonitor.Server_ID_Trigger
--BEFORE  INSERT ON AlexMonitor.Server
--For each row
--BEGIN
--    SELECT Server_ID_Seq .NEXTVAL INTO:NEW.Server_ID from dual;
--END;
--
--
--/*Create sequence and trigger for RobotManagement id to increased in automatic*/
--CREATE  SEQUENCE  AlexMonitor.Robot_ID_Seq Minvalue 1 Maxvalue 10000000000
--INCREMENT BY 1
--START WITH 1;
--
--CREATE OR REPLACE TRIGGER AlexMonitor.Robot_ID_Trigger
--BEFORE  INSERT ON AlexMonitor.RobotManagement
--For each row
--BEGIN
--    SELECT Robot_ID_Seq .NEXTVAL INTO:NEW.Robot_ID from dual;
--END;
--
--
--/*Create sequence and trigger for Station id to increased in automatic*/
--CREATE  SEQUENCE  AlexMonitor.Station_ID_Seq Minvalue 1 Maxvalue 10000000000
--INCREMENT BY 1
--START WITH 1;
--
--CREATE OR REPLACE TRIGGER AlexMonitor.Station_ID_Trigger
--BEFORE  INSERT ON AlexMonitor.Station
--For each row
--BEGIN
--    SELECT Station_ID_Seq .NEXTVAL INTO:NEW.Station_ID from dual;
--END;
--
--
--/*Create sequence and trigger for TestStation id to increased in automatic*/
--CREATE  SEQUENCE  AlexMonitor.TestStation_ID_Seq Minvalue 1 Maxvalue 10000000000
--INCREMENT BY 1
--START WITH 1;
--
--CREATE OR REPLACE TRIGGER AlexMonitor.TestStation_ID_Trigger
--BEFORE  INSERT ON AlexMonitor.TestStation
--For each row
--BEGIN
--    SELECT TestStation_ID_Seq .NEXTVAL INTO:NEW.TestStation_ID from dual;
--END;

 


/*Create sequence and trigger for RobotManagement id to increased in automatic*/
CREATE  SEQUENCE  AlexMonitor.StationRealTime_ID_Seq Minvalue 1 Maxvalue 10000000000
INCREMENT BY 1
START WITH 1;

CREATE OR REPLACE TRIGGER AlexMonitor.StationRealTime_ID_Trigger
BEFORE  INSERT ON AlexMonitor.StationRealTime
For each row
BEGIN
    SELECT StationRealTime_ID_Seq .NEXTVAL INTO:NEW.STATION_REAL_TIME_ID from dual;
END;

 

/*Create sequence and trigger for RobotManagement id to increased in automatic*/
CREATE  SEQUENCE  AlexMonitor.RobotRealTime_ID_Seq Minvalue 1 Maxvalue 10000000000
INCREMENT BY 1
START WITH 1;

CREATE OR REPLACE TRIGGER AlexMonitor.RobotRealTime_ID_Trigger
BEFORE  INSERT ON AlexMonitor.RobotRealTime
For each row
BEGIN
    SELECT RobotRealTime_ID_Seq .NEXTVAL INTO:NEW.R_REAL_TIME_ID from dual;
END;


CREATE OR REPLACE TRIGGER AlexMonitor.RobotRealTime_ID_Trigger
BEFORE  INSERT ON AlexMonitor.RobotRealTime
For each row
BEGIN
    SELECT RobotRealTime_ID_Seq .NEXTVAL INTO:NEW.R_REAL_TIME_ID from dual;
END;


CREATE  SEQUENCE  AlexMonitor.ServerRealTime_ID_Seq Minvalue 1 Maxvalue 10000000000
INCREMENT BY 1
START WITH 1;

CREATE OR REPLACE TRIGGER AlexMonitor.ServerRealTime_ID_Trigger
BEFORE  INSERT ON AlexMonitor.ServerRealTime
For each row
BEGIN
    SELECT ServerRealTime_ID_Seq .NEXTVAL INTO:NEW.SERVER_REAL_TIME_ID from dual;
END;


CREATE  SEQUENCE  AlexMonitor.ProduceLineRealTime_ID_Seq Minvalue 1 Maxvalue 10000000000
INCREMENT BY 1
START WITH 1;

CREATE OR REPLACE TRIGGER AlexMonitor.LineRealTime_ID_Seq_Trigger
BEFORE  INSERT ON AlexMonitor.ProduceLineRealTime
For each row
BEGIN
    SELECT ProduceLineRealTime_ID_Seq .NEXTVAL INTO:NEW.P_L_REAL_TIME_ID from dual;
END;

CREATE SEQUENCE ALEXMONITOR.STATIONREALTIME_ID_SEQ
  START WITH 13781
  MAXVALUE 10000000000
  MINVALUE 1
  NOCYCLE
  CACHE 20
  NOORDER;
  
 

CREATE OR REPLACE TRIGGER ALEXMONITOR.StationRealTime_ID_Trigger
BEFORE  INSERT ON ALEXMONITOR.StationRealTime For each row
BEGIN
    SELECT StationRealTime_ID_Seq .NEXTVAL INTO:NEW.STATION_REAL_TIME_ID from dual;
END;

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/26851211/viewspace-753062/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2012-04-04

  • 博文量
    59
  • 访问量
    65950