SQLServer2008/2012 删除所有表视图存储过程 -------------------删除所有的表-------------------use xuwenbin111--/第1步**********删除所有表的外键约束*************************/DECLARE c1 cursor forselect 'alter table ['+ object_name(parent_obj) + '] drop constraint ['+name+']; 'from…
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…
sql 判断 函数 存储过程是否存在的方法 (2010-12-03 10:08:57) 转载▼     下面为您介绍sql下用了判断各种资源是否存在的代码,需要的朋友可以参考下,希望对您学习sql的函数及数据库能够有所帮助.库是否存在if exists(select * from master..sysdatabases where name=N'库名')print 'exists'elseprint 'not exists'----------------- 判断要创建的表名是否存在if ex…
table 表 --delete table drop table Test1; -- Create table create table TEST1 (   ID     NUMBER,   T_NAME VARCHAR2(100),   DT     DATE ); -- 添加注释 comment on column TEST1.T_NAME is '名称'; --添加age字段 alter table Test1 add (age  NUMBER(8)); --删除字段 alter tab…
-- Oracle 11 G --20160921 涂聚文再次修改 --Geovin Du --GetTables SELECT owner, object_name, created FROM all_objects WHERE (owner in ( select USERNAME from user_users )) AND object_type = 'TABLE' ORDER BY owner, object_name; ---GEOVIN SELECT owner, object_n…
sql server 2005: --SQL SERVER 2005 生成代码需要知道的SQL语句 use LibrarySystem --查询当前数据库所有表和其的主键字段,字段类型,长度,是否为空值 SELECT d.name as 'TableName',a.name as 'FieldName',b.name as 'TypeName',a.length as 'Length',a.isnullable as 'IS_NULL' FROM syscolumns a, systypes b…
#数据库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'; #表结构 字段名, 类…
如果由于外键约束删除table失败,则先删除所有约束:   --/第1步**********删除所有表的外键约束*************************/   DECLARE c1 cursor for select 'alter table ['+ object_name(parent_obj) + '] drop constraint ['+name+']; ' from sysobjects where xtype = 'F' open c1 declare @c1 varcha…
[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…
declare proccur cursor     for         select [name] from sysobjects where type='P' declare @procname varchar() open proccur fetch next from proccur into @procname ) begin       --exec('drop proc ' + @procname)  --本句被注释,使用时请取消     print(@procname + '…