truncate語句實例 SQLServer中truncate,delete和drop的異同點?
SQLServer中truncate,delete和drop的異同點?——刪除表結構,刪除其中的數(shù)據(jù),刪除表上的索引,等等。Drop table name——清除數(shù)據(jù),只截短數(shù)據(jù)table name—
SQLServer中truncate,delete和drop的異同點?
——刪除表結構,刪除其中的數(shù)據(jù),刪除表上的索引,等等。Drop table name——清除數(shù)據(jù),只截短數(shù)據(jù)table name——根據(jù)條件刪除數(shù)據(jù)delete from table name where condition——刪除所有數(shù)據(jù),但不釋放空間delete from table name。所以,delete from table name和truncate table表名看起來是一樣的,但是truncate會釋放數(shù)據(jù)庫的空間,而delete不會。刪除表名也可以釋放空間。執(zhí)行truncate和drop后,觸發(fā)器、存儲過程、函數(shù)等將無效。Truncate可以重新編譯,但是在drop之后,它可能會永久無效