[http://www.th7.cn/db/mssql/2011-07-07/10127.shtml#userconsent#] 删除用户表 .select 'DROP TABLE '+name from sysobjects where type = 'U' 删除视图 .select 'DROP VIEW '+name from sysobjects where type = 'V' 删除存储过程 .select 'DROP PROC '+name from sysobjects where…
1.删除外键约束 DECLARE c1 cursor for select 'alter table ['+ object_name(parent_obj) + '] drop constraint ['+name+']; ' from sysobjects where xtype = 'F' open c1 ) fetch next from c1 into @c1 ) begin exec(@c1) fetch next from c1 into @c1 end close c1 deall…
#数据库MySQL 6.7 use sakila; #查询表名 show tables; # SELECT TABLE_NAME,TABLE_ROWS FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='sakila'; select column_name from information_schema.columns where table_schema='sakila' and table_name='actor'; #表结构 字段名, 类…
使用SQL脚本删除冗余的视图和表 SQL脚本删除视图信息 USE DatabaseGOIF OBJECT_ID('ViewName')IS NOT NULLBEGINDROP VIEW ViewNameENDGO SQL脚本删除表信息 USE DatabaseGOIF EXISTS (SELECT * FROM dbo.sysobjects WHERE ID = OBJECT_ID(N'dbo.TableName') AND OBJECTPROPERTY (id,N'IsUserTable'…
1.删除所有表 select 'drop table '+name+';' from sys.tables where name like 'DataSyncV1DelaySample%' or name like 'DataSyncV2DelaySample%' 2.递归查询 使用关键字with as with temp ( [Id], [parentid]) as ( select Id, ParentId from SysLocation where ParentId = @ParentI…