SQL Server删除表及删除表中数据的方法
删除表的SQL语句为:
drop table 表名称
删除表数据有两种方法:delete和truncate。
delete 语句:
delete语句用于删除表中的行。
语法
delete from 表名称 where 列名称 = 值
truncate语法:
truncate table 表名称
delete和truncate的区别如下:
1、delete可以删除表中的一条或多条数据,也可以删除全部数据;而truncate只能将表中的全部数据删除。
2、truncate 比 delete速度快,且使用的系统和事务日志资源少。
truncate 操作后的表比Delete操作后的表要快得多。
当表被清空后表和表的索引讲重新设置成初始大小,而delete则不能(表的结构、属性和索引都是完整的)。