清除表與儲存過程

2021-05-25 10:01:46 字數 931 閱讀 7509

--/第1步**********刪除所有表的外來鍵約束*************************/

declare c1 cursor for

select 'alter table ['+ object_name(parent_obj) + '] drop constraint ['+name+']; '

from sysobjects

where xtype = 'f'

open c1

declare @c1 varchar(8000)

fetch next from c1 into @c1

while(@@fetch_status=0)

begin

exec(@c1)

fetch next from c1 into @c1

endclose c1

deallocate c1

--/第2步

--刪除所有表--

declare @tname varchar(8000)

set @tname=''

select @tname=@tname + name + ',' from sysobjects where xtype='u'

select @tname='drop table ' + left(@tname,len(@tname)-1)

exec(@tname)

--刪除所有儲存過程--

declare @tname varchar(8000)

set @tname=''

select @tname=@tname + name + ',' from sysobjects where xtype='p'

select @tname='drop procedure ' + left(@tname,len(@tname)-1)

exec(@tname)

mysql儲存過程表 mysql儲存過程和表命令

show procedure status 2.顯示某個儲存過程的詳細資訊 sp為儲存過程名稱 show create procedure sp 3.顯示當前庫中所有表 show tables 4.顯示某個表的建表語句 test為表名 show create table test 5.刪除儲存過程 ...

儲存過程建立表

create or replace procedure test1 tname varchar2 is v createsql varchar2 400 v dropsql varchar2 100 v count number 9 begin v createsql create table tn...

儲存過程與儲存函式

plsql中語法 create or replace procedure 過程名 引數名 in out 型別 asbegin end 宣告pro add sal儲存過程,作用是給指定員工漲1000元工資,並列印出漲前和漲後工資 create orreplace procedure pro add s...