avatar
Trigger questions# Database - 数据库
k*r
1
I want to write a trigger. Whenever someone tries to delete the rows of a
table, then the trigger will be fired and those deleted rows will be inserted
into a temp table. In addition, the temp table also need a column to record
the date and time when each row is deleted. Please give me some advices.
Thanks a lot!
avatar
aw
2
if you're using SQL Server.
CREATE TRIGGER [TRIGGER NAME] ON [table_name]
FOR DELETE
AS
INSERT INTO TEMP_TABLE
SELECT *, current_timestamp FROM Deleted
Deleted is a system virtual table in SQL server.

inserted

【在 k******r 的大作中提到】
: I want to write a trigger. Whenever someone tries to delete the rows of a
: table, then the trigger will be fired and those deleted rows will be inserted
: into a temp table. In addition, the temp table also need a column to record
: the date and time when each row is deleted. Please give me some advices.
: Thanks a lot!

avatar
k*r
3
Thanks a lot!

record

【在 aw 的大作中提到】
: if you're using SQL Server.
: CREATE TRIGGER [TRIGGER NAME] ON [table_name]
: FOR DELETE
: AS
: INSERT INTO TEMP_TABLE
: SELECT *, current_timestamp FROM Deleted
: Deleted is a system virtual table in SQL server.
:
: inserted

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。