在sql中删除和截断之间的差异?删除的文件或表格去哪里? [英] Diff between delete and truncate in sql ? where deleted files or tables goes?

查看:80
本文介绍了在sql中删除和截断之间的差异?删除的文件或表格去哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



任何1可以告诉我什么是

sql.on中删除和截断之间的差异哪种情况,

我们将选择其中一个选项。

假如我们删除一个表,它在哪里?

假设我们截断一个表,哪里有它去了吗?



提前感谢



Naveen ...

解决方案

从数据库中删除表:



drop table [table]





从表中删除数据:





从[table]中删除







truncate table [table]





drop 一个它和它的记录一起消失了。



中删除​​时,内容会消失,但不会是

同样的截断除了你不能截断一个哪里有外键 - 你应该使用 delete 。您应该注意一些其他差异和问题 - 我会留给您进行研究。


参见这里 [ ^ ]。

Hi all,

Can any 1 tel me what is
Diff between delete and truncate in sql.on which scenario,
we will choose either options.
Suppose if we delete a table ,where does it goes ?
Suppose if we truncate a table ,where does it goes ?

thanks in advance

Naveen...

解决方案

To delete a table from the database:

drop table [table]


To remove data from a table:


delete from [table]

or

truncate table [table]


When you drop a table it, along with it''s records, is gone.

When you delete from a table the content goes but not the table.
Same for truncate other than you can''t truncate a table where there are foreign keys - you should use delete. There are some other differences and issues you should be aware of - I''ll leave that to you to do the research.


See here[^].


这篇关于在sql中删除和截断之间的差异?删除的文件或表格去哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆