创建一个数据库 CREATE DATABASE IF NOT EXISTS sql_example 删除一个数据库 DROP DATABASE IF EXISTS sql_example 创建数据表 USE sql_example; DROP TABLE IF EXISTS customers; C ...
use 数据库名(是要删除表的所在的那个数据库的名称)GOdeclare @sql varchar(8000)while (select count(*) from sysobjects where type='U')>0beginSELECT @sql='drop table ' + nameFR...
use 数据库名(是要删除表的所在的那个数据库的名称)GOdeclare @sql varchar(8000)while (select count(*) from sysobjects where type='U')>0beginSELECT @sql='drop table ' + nameFROM sysobjectsWHERE (type = 'U')ORDER BY 'drop t
--删除所有约束DECLARE c1 cursor forselect'alter table ['+ object_name(parent_obj)+'] drop constraint ['+name+']; 'from sysobjectswhere xtype ='F'open c1declare @c1 varchar(8000)fetch next from c1 into @c1while(@@fetch_status=0)beginexec(@c1) fetch next from c1 into @c1endcl
declare c cursor for select NAME from sysobjects where xtype='U' declare @t varchar(200) open c fetch next from c into @t while @@FETCH_STATUS=0 begin ...