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
• 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
相关文章推荐
- ocp 047-40 User OE, the owner of the ORDERS table, issues the following command:
- Refreshing One Column based on the value of Another Column in ADFdi Table
- 053-23 How can you reverse the effects of an ALTER DISKGROUP … DROP DISK command if it has not yet c
- 62.You are in the middle of a transaction updating a very important table. The machine on which a da
- Research on Computer Aided Design Method for the particles distribution of Table-tennis racket
- MySQL 之 The definition of table 'p' prevents operation UPDATE on table 'post'.
- sed: 1: "grep": extra characters at the end of g command----sed on mac
- what is the use of truncate command
- User SCOTT executes the following command on the EMP table but has not issued COMMIT, ROLLBACK, or a
- 23 How can you reverse the effects of an ALTER DISKGROUP … DROP DISK command if it has not yet compl
- 文章3:Chalk Sounds: The Effects of Dynamic Synthesized Audio on Workspace Awareness in Distributed Groupware
- The session of user SCOTT receives the following error after executing an UPDATE command on the EMP
- asmcmd cp command on the test with transportable tablespace
- 144.You execute the following command to change the status of the SALES tablespace: SQL> ALTER TABLE
- Spoofing the ARP Table of Remote Computers on a LAN
- HAProxy Installation and Configuration on CentOS 6.4 to Mitigate The Effects of Abusive Clients--转
- Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to th
- You execute the following command to change the status of the SALES tablespace: SQL> ALTER TABLESPAC
- 77.You executed the following command to perform a backup of the USERS tablespace: SQL> ALTER TABLES
- 185.User SCOTT executes the following command on the EMP table but has not issued COMMIT, ROLLBACK,