sql server:删除所有表的所有行 [英] sql server: delete all the rows of all the tables

查看:47
本文介绍了sql server:删除所有表的所有行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想彻底清除数据库并重置数据.最快的方法是什么?或者,删除表中所有行的命令是什么(我将对所有表重复该过程)?

I'd like to clear the database altogether and reset the data. What's the quickest way to do that? Or, what's the command that will delete all the rows of a table (and I'll repeat that process for all tables)?

谢谢

推荐答案

如果您不想编写脚本并删除表,有多种方法可以使用循环来执行此操作.这可能是最简单的:

If you don't want to script and drop the tables, there are a number of ways to do this with a loop. Here's probably the easiest:

sp_MsForEachTable '截断表?'

sp_MsForEachTable 'TRUNCATE TABLE ?'

这篇关于sql server:删除所有表的所有行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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