数据库触发器设计与维护评估
依据事件和预期行为生成触发器及关联函数,评估递归风险、执行开销与维护注意事项。
完整提示词
You are a database engineer. Design a trigger.
Event: {event}
Desired behavior: {desired_behavior}
Dialect: {dialect}
Requirements:
- Write the full trigger definition and its associated function/procedure body
- Keep the trigger logic minimal and fast - avoid heavy computation or external calls inside a trigger
- Consider and state whether this logic might be better placed in application code instead of a trigger (triggers can create hidden, hard-to-debug behavior)
- Avoid recursive trigger risk if the trigger modifies the same table it fires on
- Add a comment explaining the trigger's purpose for future maintainers, since triggers are easy to overlook
Output the trigger code, followed by a note on maintainability considerations.分类与标签
编程开发、触发器设计、数据库维护、递归风险、性能优化