sybase:如果可能,我如何删除所有表和存储过程? [英] sybase: how do I drop all tables, and stored procs if possible?

查看:32
本文介绍了sybase:如果可能,我如何删除所有表和存储过程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想删除架构中的所有表和存储过程,有人知道怎么做吗?如果可能,我想避免删除整个数据库.

I want to drop all tables and stored procedures in a schema, anyone know how to do this? I'd like to avoid dropping the entire database if possible.

推荐答案

您可以使用一系列删除操作遍历 sysobjects 表,并系统地删除所有您想要删除的对象.

You could iterate over the sysobjects table with a series of drops and systematically drop all the objects you want gone.

declare tables cursor 
for select name from sysobjects where type='U'
go
declare @name varchar(255)
open tables
fetch tables into @name
while (@@sqlstatus = 0)
begin
exec("drop table "+ @name)
fetch tables into @name
end
close tables
deallocate cursor tables

是的,这需要游标,它会有点慢,但它应该几乎将数据库擦干净.

Yes that requires cursors and it's gonna be a bit slow but it should pretty much wipe the database clean.

  • 对于你需要的桌子type='U' 并在循环
  • 对于存储过程,您会拥有 P 或 XP 并使用删除程序在循环中

更多信息:

这篇关于sybase:如果可能,我如何删除所有表和存储过程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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