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

How to use trigger trigger in database

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

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces how to use the trigger trigger in the database, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, let the editor take you to understand it.

The experiments are as follows:

Query the table DEPARTMENTS under the hr user to be defined by the trigger

SQL > conn hr/hr

Connected.

SQL > select * from tab

TNAME TABTYPE CLUSTERID

COUNTRIES TABLE

DEPARTMENTS TABLE

EMPLOYEES TABLE

EMP_DETAILS_VIEW VIEW

JOBS TABLE

JOB_HISTORY TABLE

LOCATIONS TABLE

REGIONS TABLE

8 rows selected.

-- create a trigger:

SQL > CREATE OR REPLACE TRIGGER tr_dept_time

2 BEFORE INSERT OR DELETE OR UPDATE

3 ON departments

4 BEGIN

5 IF (TO_CHAR (sysdate,'DAY') IN ('Saturday', 'Sunday') OR (TO_CHAR (sysdate,' HH24:MI') NOT BETWEEN'08 sysdate,'DAY' 30 'AND' 18 sysdate,'DAY' 00') THEN

6 RAISE_APPLICATION_ERROR (- 20001, 'not working hours, cannot modify departments table')

7 END IF

8 END

9 /

Trigger created.

Thank you for reading this article carefully. I hope the article "how to use the trigger trigger in the database" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

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