Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

An example of oracle trigger, sequence and Task Planning exercise

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Today, I practiced the oracle task plan in my spare time, the details are as follows

1. Create table TBL_TIME

Create table tbl_time (id number not null, / * id number * / vsecond varchar2 (2), / * seconds * / vtime varchar2 (10) / * current time * /)

two。 Create sequence seq_tbltime

Create sequence seq_tbltimestart with 1increment by 1nomaxvaluenocyclecache 20

3. Create trigger tr_tbltimeseq

Create or replace trigger tr_tbltimeseq/* function description: increments the table tbl_time (id) using seq_tbltime sequence before inserting data * / before insert on tbl_timefor each row begin select seq_tbltime.nextval into: new.id from dual; end tr_tbltimeseq

4. Create a stored procedure proc_addtime

Create or replace procedure proc_addtime/* function description: insert the current time point * / asd_time1 date;d_time2 date;n_timediff number (2); I number (2); begin select sysdate into d_time1 from dual; insert into tbl_time values (1 to_char) into the table tbl_time every 5 seconds within a minute; iasd_time1 date;d_time2 date;n_timediff number 5; while i select * hhss') ID VSECOND VTIME- 1 09 201407030509 2 14 201407030514 3 19 201407030519 4 24 201407030524 529 201407030529 6 34 201407030534 7 39 201407030539 8 44 201407030544 9 49 201407030549

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report