您的位置:首页 > Web前端

The effects of the TRUNCATE command on a table

2013-07-08 22:55 429 查看
The effects of using this command are as follows:

• The table is marked as empty by setting the high-water mark (HWM)to the

beginning of the table, making its rows unavailable.

• No undo data is generated and the command commits implicitlybecause TRUNCATE

TABLE is a DDL command.

• Corresponding indexes are also truncated.(索引也会清空)

• A table that is being referenced by a foreign key cannot betruncated.

• The delete triggers do not fire when this command is used.

(delete trigger里面的内容不会执行,但对象仍然存在,既删除触发器不会被触发执行。)

关于删除触发器(delete trigger):

有两个表 A 和 B,

A的结构为 UserID,PropID

B的结构为 UserID, PropRight

我想写一个DELETE的触发器,当删除A里的记录时,更改B表中对应 UserID 的 权限(PropRight)

CREATE TRIGGER A_table_delete

ON A FOR DELETE

BEGIN

DECLARE@UserID nvarchar(128);

SET @UserID= (SELECT UserID FROM deleted);

UPDATE B setPropRight=xxx WHERE UserID=@UserID;

END

GO
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐