In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces the use of triggers 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 flip-flop has two steady states, which can represent the binary code 0 and 1 respectively, and can maintain the steady state when there is no external trigger; under the external trigger, the two steady states can be converted to each other, and the converted stable state can be maintained for a long time. This makes the flip-flop can remember binary information and is often used as a binary storage cell.
Trigger is a method that SQL server provides to programmers and data analysts to ensure data integrity. It is a special stored procedure related to table events. Its execution is not called by the program or started manually, but triggered by events, such as activating the execution of a table when it is insert,delete,update. Triggers are often used to strengthen data integrity constraints and business rules.
Trigger action
1. Force verification or conversion of data before writing to the data table.
2. When an error occurs in the trigger, the result of the change will be undone.
3. Some database management systems can use triggers for data definition language (DDL), which are called DDL triggers.
4. The abnormal instruction (INSTEADOF) can be replaced according to the specific situation.
Trigger classification
1. ML trigger
When the data in the table in the database changes, including any insert,update,delete operation, if we write a corresponding DML trigger to the table, the trigger executes automatically. The main role of DML triggers is to enforce business rules, and to extend SqlServer constraints, default values, and so on. Because we know that constraints can only constrain data in the same table, while triggers can execute arbitrary Sql commands.
2. DDL trigger
It is a new trigger added by SqlServer2005, which is mainly used to audit and standardize the operation of tables, triggers, views and other structures in the database. For example, in modifying tables, modifying columns, adding tables, adding columns, and so on. It is executed when the database structure changes, and we mainly use it to record the modification process of the database and to restrict programmers' changes to the database, such as not allowing certain specified tables to be deleted.
3. Login trigger
The login trigger fires the stored procedure in response to the LOGIN event. This event is raised when a user session is established with the SQLServer instance. The login trigger fires after the authentication phase of the login is complete and before the user session is actually established. Therefore, all messages from within the trigger that typically reach the user, such as error messages and messages from PRINT statements, are delivered to the SQLServer error log. If authentication fails, the login trigger is not fired.
Advantages of trigger
Triggers can cascade changes through related tables in the database, but cascading referential integrity constraints can make these changes more efficient. Triggers can enforce constraints that are more complex than those defined by CHECK constraints. Unlike CHECK constraints, triggers can reference columns in other tables. For example, triggers can use SELECT in another table to compare inserted or updated data and perform other actions, such as modifying data or displaying user-defined error messages. Triggers can also evaluate the table status before and after data modification and take countermeasures according to their differences. Multiple similar triggers (INSERT, UPDATE, or DELETE) in a table allow multiple different countermeasures to be taken in response to the same modification statement.
Steady state of flip-flop
(1) the flip-flop has two steady states, which can represent the binary code 0 and 1 respectively, and can maintain the steady state without external trigger.
(2) under the external trigger, the two steady states can be converted to each other (called flip-flop), and the converted stable state can be maintained for a long time, which makes the flip-flop can remember binary information and is often used as a binary memory cell.
Thank you for reading this article carefully. I hope the article "what is the use of triggers in the database" shared by the editor will be helpful to everyone? at the same time, I also hope that you will support 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.